目前最新swift是4.1,但是pod导入的三方可能是3.3版本,此时使用pod导入三方可在podfile里配置以下内容
# Swift 版本声明
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['对应三方1', '对应三方2'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.3'
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
else
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
end
整个podfile为
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
inhibit_all_warnings!
target 'FoxBuy' do
## 此处是三方库
## ...
end
# Swift 版本声明
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['对应三方1', '对应三方2'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.3'
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
else
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
end