xcode iOS:阐明不同的搜索路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8342982/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:37:56  来源:igfitidea点击:

iOS: Clarify different Search Paths

iosxcodeios-frameworksbuild-settings

提问by cschuff

There are three different search paths in XCode Build Settings:

XCode 构建设置中有三种不同的搜索路径:

  • Framework Search Path
  • Header Search Path
  • Library Search Path
  • 框架搜索路径
  • 标题搜索路径
  • 图书馆检索路径

Could anyone clarify what those paths do and what they are used for?

谁能澄清这些路径的作​​用以及它们的用途?

回答by djromero

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

框架搜索路径:除了系统框架路径之外,还可以在哪里搜索框架.framework包)。在iOS开发中用的不多,官方没有开发者iOS框架。

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.

在 Mac 开发中,如果你将一个 3rd 方框架拖到项目中,它会自动设置。否则,只需将其设置为保存框架的容器目录。

In xcconfigfiles you use this variable:

xcconfig您使用此变量的文件中:

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

Header search path: where to search for header files (.hfiles) 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.

头文件搜索路径.h除了系统路径之外,还可以在哪里搜索头文件(文件)。如果您使用的是 3rd 方库,通常会需要它。将其设置为包含头文件的目录。如果您使用目录来包含标题(例如:),#import "mylibrary/component.h"请将其设置为父目录。

In xcconfigfiles you use this variable:

xcconfig您使用此变量的文件中:

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 (.afiles) into the project. To set it manually, use the directory where the library is located.

库搜索路径:除了系统路径之外,还可以在哪里搜索库文件。如果您将库(.a文件)拖到项目中,Xcode 将自动设置它。要手动设置,请使用库所在的目录。

In xcconfigfiles you use this variable:

xcconfig您使用此变量的文件中:

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

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

这三个都可以保存一个路径列表,用引号引起来,用空格分隔。

回答by Mark

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).

这些用于搜索不在系统搜索路径中的框架、头文件或库(如 QTKit.Framework、标准 C++ 头文件等)。

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.

我最常见的用途是在我的代码中使用 boost 标头库 (*.hpp) 文件,我将相对路径“../lib/Boost/1.46.1”添加到标头搜索路径。

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.

我发现最好在项目级别而不是在每个目标中添加它。这样,目标就继承了这一点,如果我更新 boost 版本,它只需要在一个地方进行更改。