解決庫移位出現的 ld: library not found for -lXXX

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

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

pod install

回車,

Analyzing dependencies
Removing XXX 
...

然后把XXX拖進項目另一個工程目錄下,commond+ B,出現error:

"xxx.h" file  no find

出現這個這個正常,因為有緩存,于是shift + cmmond + k,清除緩存,再commod + B,重新編譯。

這個時候,本文重點描述的幺蛾子error出現了:

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

解決方法:
查找網絡資源:

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

這里的處理方式是:

在主項目中打開Build Settings -> Other Link Flags 打開以后,發現里面存在對應的庫名稱,前面還有一個前綴修飾: -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.

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。