解决库移位出现的 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)

解决方法:
查找网络资源:

  • ios 链接库的问题
  • 完美解决:"library not found for - "

第二篇里面提到Link binary With LibrariesLibrary Search Path,但是都没有解决目前这个问题。但是已经很接近error的真相了:依赖路径不对。

这里的处理方式是:

在主项目中打开Build Settings -> Other Link Flags 打开以后,发现里面存在对应的库名称,前面还有一个前缀修饰: -lxxx。把它干掉。

commod + R

屏幕显示:


解决库移位出现的 ld: library not found for -lXXX_第1张图片
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.

你可能感兴趣的:(解决库移位出现的 ld: library not found for -lXXX)