最近計劃把公司的項目重構一下,第一步就是引入CocoaPods(以下簡稱pods)來管理第三方庫。但是這第一步就不是太順利。
首先建好Podfile,并在命令行中輸入pod install
,結果報以下錯誤
[!] The XXX target overrides the 'OTHER_LDFLAGS' build setting defined in
'Pods/Target Support Files/Pods/Pods.debug.xcconfig'.
This can lead to problems with the CocoaPods installation
- Use the '$(inherited)' flag, or
- Remove the build settings from the target.
[!] The 'SubWayWifi [Release]' target overrides the 'OTHER_LDFLAGS' build setting defined in
'Pods/Target Support Files/Pods/Pods.release.xcconfig'.
This can lead to problems with the CocoaPods installation
- Use the '$(inherited)' flag, or
- Remove the build settings from the target.
現在打開有pods建好的workspace文件,嘗試編譯,會報ld: library not found for -lPods
錯誤,原因就是工程里面的設置項覆蓋了pods中xcconfig中的設置。解決辦法就是在build setting->other linker flag中,加上$(inherited)即可。
OK,重新安裝pod試試,由于我們已經進行過一次安裝,所以本次只用更新一次即可,在命令行中輸入pod update
,現在沒有報任何錯誤。但是當我嘗試編譯工程的時候,又報了一個錯誤:ld: library not found for -lReactiveCocoa
。咋又找不到相應的第三方庫了呢?好吧,繼續查資料。
最后還是在cocoapods的官網Troubleshooting找到的解決辦法。在Edit Scheme中,找到Build項,點擊+號,找到Pods靜態庫,點擊Add。再嘗試編譯,編譯通過。