1. 程式人生 > >解決 ld: library not found for -lPods的問題

解決 ld: library not found for -lPods的問題

最近計劃把公司的專案重構一下,第一步就是引入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。再嘗試編譯,編譯通過。