-
Notifications
You must be signed in to change notification settings - Fork 41
/
xcodeproj-prep.rb
44 lines (31 loc) · 1.24 KB
/
xcodeproj-prep.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'xcodeproj'
enable_async = false
swift_async_flags = ["-Xfrontend", "-enable-experimental-concurrency", "-Xfrontend", "-disable-availability-checking"]
release_mode_targets = ["Antlr4", "ObjcParserAntlr", "SwiftSyntax"]
project_path = 'SwiftRewriter.xcodeproj'
# @type [Xcodeproj::Project]
project = Xcodeproj::Project.open(project_path)
configurations = project.build_configurations
if enable_async
puts "Checking if concurrency is enabled..."
configurations.each do |config|
# @type [String]
other_flags = project.build_settings(config.name)["OTHER_SWIFT_FLAGS"]
if !other_flags.include?(swift_async_flags)
puts "Concurrency is disabled for config #{config.name}, enabling..."
other_flags.concat(swift_async_flags)
project.build_settings(config.name)["OTHER_SWIFT_FLAGS"] = other_flags
end
end
puts "Done!"
end
puts "Marking targets #{release_mode_targets} to compile in optimized mode ..."
configurations.each do |config|
project.targets.each do |target|
if release_mode_targets.include?(target.name)
target.build_settings(config.name)["SWIFT_OPTIMIZATION_LEVEL"] = "-O"
end
end
end
puts "Done!"
project.save