Cocoapods
對 Swift
的支持不是很好阅束,每次 Xcode
或 Cocoapods
版本更新晤锹,總有一些意外發(fā)生烧董,這里總結(jié)下這一年半以來遇到的各種錯誤及其解決辦法州疾,省的下次遇到又要Google一遍督暂。
安裝淘寶 Ruby
源的問題 Error fetching http://ruby.taobao.org/
由于墻的原因揪垄,安裝 Cocoapods
時有可能執(zhí)行完install命令半天都沒反應,這時就需要將 Ruby
的默認源 https://rubygems.org/
替換成淘寶的源逻翁,但會遇到以下錯誤:
$ gem sources -a http://ruby.taobao.org/
$ Error fetching http://ruby.taobao.org/:
bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
這是因為饥努,淘寶把源從 http
換成 https
了,而網(wǎng)上大多數(shù)教程是舊的八回,沒有更新酷愧,正確的是:
$ gem sources -a https://ruby.taobao.org/
Pod Error in Xcode “Id: framework not found Pods”
執(zhí)行完 pod install
后,打開 workspace 文件缠诅,編譯溶浴,遇到以下錯誤:
Id: framework not found Pods clang: error: linker command failed with exit code 1 (use -v to see invocation)
stackoverflow解決方法的:http://stackoverflow.com/questions/31139534/pod-error-in-xcode-id-framework-not-found-pods
步驟如下:
- 打開 workspace
- 點擊 Xcode 左邊的藍色項目圖標
- 在右邊選擇對應的 Target
- 單擊 Genral 的 tab
- 找到 Linked Frameworks and Libraries 的分組
- 刪除 Pods frameworks(或 刪除Embedded Binaries下的Pod.framework)
- 關(guān)閉 Xcode,運行 pod update滴铅,
- Clean戳葵,然后重新 Run/Build
提交App到Itunes Connect時報錯 ERROR ITMS-90635
提交 App 到 ITunes Connect 審核時報以下錯誤:
ERROR ITMS-90635: "Invalid Mach-O Format. The Mach-O in bundle "XXXX!.app/Frameworks/BRYXBanner.framework" isn’t consistent with the Mach-O in the main bundle. The main bundle Mach-O contains armv7(machine code) and arm64(machine code), while the nested bundle Mach-O contains armv7(bitcode) and arm64(bitcode). Verify that all of the targets for a platform have a consistent value for the ENABLE_BITCODE build setting."
WARNING ITMS-90080: "The executable 'Payload/XXXX!.app/Frameworks/Bolts.framework' is not a Position Independent Executable. Please ensure that your build settings are configured to create PIE executables. For more information refer to Technical Q&A QA1788 - Building a Position Independent Executable in the iOS Developer Library."
stackoverflow 解決方法:http://stackoverflow.com/questions/37634627/upload-to-itunesconnect-failing
這是因為 Xcode 7 (或以上)默認支持 bitcode
,而你的項目關(guān)閉了bitcode
(即在 【Build Settings】 中設置了 【Enable Bitcode】為 NO)汉匙,需要在 Podfile
中進行額外配置:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
升級Xcode8后報錯“target overrides the EMBEDDED_CONTENT_CONTAINS_SWIFT
build setting”
升級 Xcode 8后拱烁,運行 Pod install
, 報以下錯誤:
[!] The X target overrides the `EMBEDDED_CONTENT_CONTAINS_SWIFT` build setting defined in `X’. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `X` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `X'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
stackoverflow 解決方法:http://stackoverflow.com/questions/39569743/errors-after-updating-to-xcode-8-no-such-module-and-target-overrides-the-em
步驟如下:
- 找到 【Project/Targets】-->【Project Name】-->【Build Settings】
- 搜索 "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES"
- 右鍵 "debug"噩翠,選擇 "other"戏自,輸入 $(inherited)
- "release" 也做同樣的操作,然后重新 "pod install"
如下圖:
指定編譯版本
指定Target的 Swift 編譯版本為 3.0
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |configuration|
configuration.build_settings['SWIFT_VERSION'] = "3.0"
end
end
end
但如果是 Objective-C 跟 Swift 混編的項目, 想要引入 OC 的第三方庫的話, 還需要添加另一項參數(shù)
configuration.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO'