解決庫移位出現(xiàn)的 ld: library not found for -lXXX

在Pod里,有個第三方庫不更新了,但是里面的警告挺多的,開發(fā)組老大讓我把它單獨(dú)挪出來,把警告處理掉,期間遇到了一個坑,于是就有了這篇文章。

如約,Pods工程目錄下,把Posfile里的那個庫注釋掉,然后:

pod install

回車,

Analyzing dependencies
Removing XXX 
...

然后把XXX拖進(jìn)項(xiàng)目另一個工程目錄下,commond+ B,出現(xiàn)error:

"xxx.h" file  no find

出現(xiàn)這個這個正常,因?yàn)橛芯彺妫谑莝hift + cmmond + k,清除緩存,再commod + B,重新編譯。

這個時候,本文重點(diǎn)描述的幺蛾子error出現(xiàn)了:

ld: library not found for -lXXXXX(XXXX就是對應(yīng)的庫名稱)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

解決方法:
查找網(wǎng)絡(luò)資源:

第二篇里面提到Link binary With LibrariesLibrary Search Path,但是都沒有解決目前這個問題。但是已經(jīng)很接近error的真相了:依賴路徑不對。

這里的處理方式是:

在主項(xiàng)目中打開Build Settings -> Other Link Flags 打開以后,發(fā)現(xiàn)里面存在對應(yīng)的庫名稱,前面還有一個前綴修飾: -lxxx。把它干掉。

commod + R

屏幕顯示:


Never say never

其他鏈接:
【解決方法】ld: warning: directory not found for option
# iOS: Clarify different Search Paths

摘錄如下:

Q: here are three different search paths in XCode Build Settings:

  • Framework Search Path
  • Header Search Path
  • Library Search Path
    Could anyone clarify what those paths do and what they are used for?

A:
Framework search path: where to search frameworks (.framework bundles) in addition to system frameworks paths. Not used very much in iOS development, officially there is no developer iOS frameworks.

In Mac development, it's set automatically if you drag a 3rd party framework into the project. Otherwise, just set it to the container directory where you saved the framework.

In xcconfig files you use this variable:

FRAMEWORK_SEARCH_PATHS = "/path/to/frameworks/container/directory"

Header search path: where to search for header files (.h files) in addition to system paths. Usually you'll need it if you are using a 3rd party library. Set it to the directory where you have the header files. If you use a directory to include the header (example: #import "mylibrary/component.h") set it to the parent directory.

In xcconfig files you use this variable:

HEADER_SEARCH_PATHS = "/path/to/headers/container/directory"

Library search path: where to search for library files in addition to system paths. Xcode will set it automatically if you drag a library (.a files) into the project. To set it manually, use the directory where the library is located.

In xcconfig files you use this variable:

LIBRARY_SEARCH_PATHS = "/path/to/libraries/container/directory" 

All three can hold a list of paths, with quotes, separated by space.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容