指定编译版本
指定Target
的 Swift
编译版本为 3.3
post_install do |installer|
# Your list of targets here.
myTargets = ['Starscream']
installer.pods_project.targets.each do |target|
if myTargets.include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.3'
end
end
end
end
但如果是 Objective-C
跟 Swift
混编的项目, 想要引入 OC
的第三方库的话, 还需要添加另一项参数
configuration.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO'
当项目target
比较多的时候应写在最外面
举个🌰:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
def ntt_rd_pods
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'Starscream', '2.0.4'
end
target 'ntt-rd-showcase' do
ntt_rd_pods
end
target 'ntt-rd-release' do
ntt_rd_pods
end
post_install do |installer|
# Your list of targets here.
myTargets = ['Starscream']
installer.pods_project.targets.each do |target|
if myTargets.include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.3'
end
end
end
end
注: Xcode
版本9.4
, Swift
语言4.1
, 但是Starscream
是3.3
, 所以写了这段代码, 能避免在合并代码的时候每次都要去更改Swift
的语言版本, 好像还会影响lib
的语言环境, 就是很麻烦, 这样写了之后省心了. 类似的库比较多的话就在 myTargets
里面加就好了
myTargets = ['Starscream', 'Starscream']
网友评论