如何告诉 Xcode 如何包含用尖括号指定的库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18026207/
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
How to tell Xcode how to include a library specified with angle brackets?
提问by openfrog
I often see open source code importing third-party libraries in Xcode / Objective-C implementation files like this:
我经常在 Xcode/Objective-C 实现文件中看到开源代码导入第三方库是这样的:
#import <ThirdPartyLibrary/utilities.h>
but when I drag & drop the file structure and files of such a library in my project, all these imports are corrupted and Xcode does not know where the files are.
但是当我在我的项目中拖放此类库的文件结构和文件时,所有这些导入都已损坏,Xcode 不知道文件在哪里。
I end up hand-modifying every import to look like:
我最终手动修改每个导入看起来像:
#import "utilities.h"
And include appears it is relative to the current physical folder on the file system. When a library split its files in folders on file system and I drag-drop it in Xcode, Xcode creates groups for the folders. But for import, I have to specify the folder name. Problem is when I am in a folder, for example:
并且 include 出现它是相对于文件系统上的当前物理文件夹的。当库在文件系统上的文件夹中拆分其文件并将其拖放到 Xcode 中时,Xcode 会为这些文件夹创建组。但是对于导入,我必须指定文件夹名称。问题是当我在一个文件夹中时,例如:
http/httpTools.h
http/httpTools.h
Then when httpTools.h wants to import utilities.h from the root, I have to change
然后当 httpTools.h 想从 root 导入utilities.h 时,我必须改变
#import <ThirdPartyLibrary/utilities.h>
to
到
#import "../utilities.h"
which is a chore. After doing this for 5 hours I thought damn, there must be a better way. Can someone explain what is the secret to teaching Xcode a new framework location that can be imported with angle brackets? The framework btw is source code. Not compiled. Just the naked code.
这是一件苦差事。这样做了 5 个小时后,我想该死的,一定有更好的方法。有人能解释一下教 Xcode 一个可以用尖括号导入的新框架位置的秘诀吗?框架 btw 是源代码。没有编译。只是裸代码。
回答by justin
Specify the include path using the compiler flag -I
, or the Xcode build settings alias HEADER_SEARCH_PATHS
. Of course, you can use build variables when doing so.
使用编译器标志-I
或 Xcode 构建设置别名指定包含路径HEADER_SEARCH_PATHS
。当然,您可以在这样做时使用构建变量。
回答by fatihk
Just stumbled upon the same issue, there are two types of search paths in Xcode:
刚刚偶然发现了同样的问题,Xcode 中有两种类型的搜索路径:
Header Search Paths
User Header Search Paths
If you add your own include folders into Header Search Paths, you can use angled brackets.
如果您将自己的包含文件夹添加到标题搜索路径中,则可以使用尖括号。