iOS: Clarify different Search Paths

谁说胖子不能爱 提交于 2019-12-20 08:23:03

问题


There 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?


回答1:


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.




回答2:


These are used for searching for Frameworks, Header files, or Libraries that are not in the system search paths (like QTKit.Framework, standard C++ header files, etc).

My most common use for this is using the boost header library (*.hpp) files in my code I add the relative path "../lib/Boost/1.46.1" to the Header Search Path.

I find it better to add this at the project level instead of in each target. That way the targets inherit this and it only needs to be changed in one place if I update the version of boost.



来源:https://stackoverflow.com/questions/8342982/ios-clarify-different-search-paths

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!