In Xcode 9 I'm getting the following suggestion for a cocoa pods project:
What does it do? And, shall I turn it on, or it will break things up?
In Xcode 9 I'm getting the following suggestion for a cocoa pods project:
What does it do? And, shall I turn it on, or it will break things up?
You can have this automatically enabled each time you run pods install
by adding the below post_install
script to the end of your Podfile
.
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
if config.name == 'Release'
config.build_settings['SWIFT_COMPILATION_MODE'] = 'wholemodule'
end
end
end
In older versions of Xcode you will need:
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
if config.name == 'Release'
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Owholemodule'
else
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone'
end
end
end
Using Whole Module Optimization allows the compiler to look at all the source files in a module. This make compilation slower but allows it to optimize generic functions even when they are in separate source files. You can see this in the final test run where the execution time is now the same for both the local and external function definitions.
In summary, if you don’t mind the extra compilation time try turning on Whole Module Optimization for your release builds.
This source should give you more insights into the Whole-module optimization
Any changes to the Pods project that Xcode makes will be blown away next time you run pod install
so the update will have to happen within Cocoapods to get rid of this warning. There is a discussion about this here.
The shorter-term solution is to add a post_install
script as Mike suggested.