更新 swift 版本和 pods 后出现链接器错误
Linker Error After Updating swift Version and pods
我正在使用 pods 安装 Alamofire 并遇到编译时错误。关于这个有很多问题但是:
删除派生数据并更新 pods 对我不起作用。
这是错误:
Alamofire/Alamofire.framework/Alamofire compiled with newer version of Swift language (3.0) than previous files (2.0) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
在你的 pod 文件的末尾添加这个并且 运行 pod install
:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
首先删除您的 pods 然后清理派生数据 - 您可以在 .podfile 上替换它。
platform :ios, '9.3'
source 'https://github.com/CocoaPods/Specs.git'
target 'Meanwise' do
use_frameworks!
pod 'pop', '~> 1.0'
pod 'Alamofire', '~> 4.0'
end
更新您的 pod 文件中的以下内容:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '2.3' || '3.0'
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO'
end
end
end
修复特定的 swift pod 版本:
代码片段:
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == '<insert target name of your pod here>'
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.2'
end
end
end
end
我正在使用 pods 安装 Alamofire 并遇到编译时错误。关于这个有很多问题但是:
删除派生数据并更新 pods 对我不起作用。
这是错误:
Alamofire/Alamofire.framework/Alamofire compiled with newer version of Swift language (3.0) than previous files (2.0) for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
在你的 pod 文件的末尾添加这个并且 运行 pod install
:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
首先删除您的 pods 然后清理派生数据 - 您可以在 .podfile 上替换它。
platform :ios, '9.3'
source 'https://github.com/CocoaPods/Specs.git'
target 'Meanwise' do
use_frameworks!
pod 'pop', '~> 1.0'
pod 'Alamofire', '~> 4.0'
end
更新您的 pod 文件中的以下内容:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '2.3' || '3.0'
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO'
end
end
end
修复特定的 swift pod 版本:
代码片段:
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == '<insert target name of your pod here>'
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.2'
end
end
end
end