krz/daybyday

iOS learning games for young children: days, months, seasons, numbers, letters, animals and more. education ios kids swift https://krz.sh/apps/daybyday/

scripts/add-test-target.rb

062549ad26607ce9e973ed2a9a7ef6f853885f83
daybyday/scripts/add-test-target.rb history · blame · raw

39 lines · 1626 bytes

 1# Adds the DayByDayTests unit test target and a shared DayByDay scheme.
 2require 'xcodeproj'
 3
 4project_path = File.expand_path('../DayByDay.xcodeproj', __dir__)
 5project = Xcodeproj::Project.open(project_path)
 6app = project.targets.find { |t| t.name == 'DayByDay' }
 7abort 'DayByDayTests already exists' if project.targets.any? { |t| t.name == 'DayByDayTests' }
 8
 9tests = project.new_target(:unit_test_bundle, 'DayByDayTests', :ios, '17.5')
10tests.add_dependency(app)
11
12group = project.new(Xcodeproj::Project::Object::PBXFileSystemSynchronizedRootGroup)
13group.path = 'DayByDayTests'
14group.source_tree = '<group>'
15project.main_group.children << group
16tests.file_system_synchronized_groups ||= []
17tests.file_system_synchronized_groups << group
18
19tests.build_configurations.each do |config|
20  s = config.build_settings
21  s['TEST_HOST'] = '$(BUILT_PRODUCTS_DIR)/DayByDay.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/DayByDay'
22  s['BUNDLE_LOADER'] = '$(TEST_HOST)'
23  s['PRODUCT_BUNDLE_IDENTIFIER'] = "#{app.build_configurations.first.build_settings['PRODUCT_BUNDLE_IDENTIFIER']}.tests"
24  s['PRODUCT_NAME'] = '$(TARGET_NAME)'
25  s['GENERATE_INFOPLIST_FILE'] = 'YES'
26  s['SWIFT_VERSION'] = '5.0'
27  s['TARGETED_DEVICE_FAMILY'] = '1,2'
28  s['SWIFT_APPROACHABLE_CONCURRENCY'] = 'YES'
29  s['SWIFT_DEFAULT_ACTOR_ISOLATION'] = 'MainActor'
30  s['DEVELOPMENT_TEAM'] = app.build_configurations.first.build_settings['DEVELOPMENT_TEAM']
31  s['CODE_SIGN_STYLE'] = 'Automatic'
32end
33
34project.save
35
36scheme = Xcodeproj::XCScheme.new
37scheme.configure_with_targets(app, tests)
38scheme.test_action.code_coverage_enabled = false
39scheme.save_as(project_path, 'DayByDay', true)