Last active
September 24, 2018 07:38
-
-
Save VincentSit/26286a1aaa3aa1d2cc8bb284eed86391 to your computer and use it in GitHub Desktop.
Change swift version base on podspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post_install do |installer| | |
installer.pods_project.targets.each do |target| | |
target.build_configurations.each do |config| | |
if config.name == 'Debug' | |
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone' | |
else | |
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Owholemodule' | |
end | |
change_directly = false | |
if change_directly | |
config.build_settings['SWIFT_VERSION'] = '4.0' | |
else | |
# Handle framework only. skip .bundle, etc... | |
next unless config.build_settings['WRAPPER_EXTENSION'].nil? | |
puts "Checking swift verion of #{target.name} in #{config.name} configuration." | |
pod_spec_meta = `pod spec cat #{target.name}` | |
if !$?.success? | |
puts "#{pod_spec_meta}. Skip." | |
next | |
end | |
pod_sepc_hash = eval(pod_spec_meta) | |
swift_version = pod_sepc_hash[:swift_version] || pod_sepc_hash[:pushed_with_swift_version] | |
next unless swift_version.nil? | |
if swift_version.to_f < 4.2 | |
puts "Swift version in #{target.name}.podspec is #{swift_version}, change to 4.0." | |
config.build_settings['SWIFT_VERSION'] = '4.0' | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment