Skip to content

Commit 966cc71

Browse files
committed
Add build helper scripts
- add_test_files.rb: Script to add test files to Xcode project - update_deployment_target.rb: Script to update iOS deployment target
1 parent 17e83ab commit 966cc71

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

scripts/add_test_files.rb

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env ruby
2+
# Script to add new test files to the SwiftDataTablesTests target
3+
# Usage: ruby scripts/add_test_files.rb
4+
5+
require 'xcodeproj'
6+
7+
project_path = File.expand_path('../Example/SwiftDataTables.xcodeproj', __dir__)
8+
project = Xcodeproj::Project.open(project_path)
9+
10+
# Find the SwiftDataTablesTests target
11+
test_target = project.targets.find { |t| t.name == 'SwiftDataTablesTests' }
12+
13+
unless test_target
14+
puts "Error: Could not find SwiftDataTablesTests target"
15+
exit 1
16+
end
17+
18+
# Find the SwiftDataTablesTests group
19+
test_group = project.main_group.find_subpath('SwiftDataTablesTests', false)
20+
21+
unless test_group
22+
puts "Error: Could not find SwiftDataTablesTests group"
23+
exit 1
24+
end
25+
26+
# New test files to add
27+
new_test_files = [
28+
'DataTableValueTypeTests.swift',
29+
'DataTableSortTypeTests.swift',
30+
'DataTableConfigurationTests.swift',
31+
'DataTableFixedColumnTypeTests.swift',
32+
'DataHeaderFooterViewModelTests.swift'
33+
]
34+
35+
# Get existing file references in the group
36+
existing_files = test_group.files.map(&:display_name)
37+
38+
# Add each new file
39+
new_test_files.each do |filename|
40+
if existing_files.include?(filename)
41+
puts "Skipping #{filename} - already in project"
42+
next
43+
end
44+
45+
file_path = File.expand_path("../Example/SwiftDataTablesTests/#{filename}", __dir__)
46+
47+
unless File.exist?(file_path)
48+
puts "Warning: #{filename} does not exist at #{file_path}"
49+
next
50+
end
51+
52+
# Add file reference to group
53+
file_ref = test_group.new_file(file_path)
54+
55+
# Add to target's compile sources
56+
test_target.source_build_phase.add_file_reference(file_ref)
57+
58+
puts "Added #{filename} to SwiftDataTablesTests target"
59+
end
60+
61+
# Save the project
62+
project.save
63+
64+
puts "Done! Project saved."
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env ruby
2+
# Script to update iOS deployment target for all targets
3+
# Usage: ruby scripts/update_deployment_target.rb
4+
5+
require 'xcodeproj'
6+
7+
project_path = File.expand_path('../Example/SwiftDataTables.xcodeproj', __dir__)
8+
project = Xcodeproj::Project.open(project_path)
9+
10+
NEW_TARGET = '12.0'
11+
12+
# Update project-level build settings
13+
project.build_configurations.each do |config|
14+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = NEW_TARGET
15+
puts "Updated project config '#{config.name}' to iOS #{NEW_TARGET}"
16+
end
17+
18+
# Update each target's build settings
19+
project.targets.each do |target|
20+
target.build_configurations.each do |config|
21+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = NEW_TARGET
22+
end
23+
puts "Updated target '#{target.name}' to iOS #{NEW_TARGET}"
24+
end
25+
26+
project.save
27+
puts "Done! Project saved with iOS deployment target #{NEW_TARGET}"

0 commit comments

Comments
 (0)