Xcode 的用户标题搜索路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18414917/
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-09 04:53:13  来源:igfitidea点击:

User Header Search Paths for Xcode

xcode

提问by lilzz

I have two paths that I want Xcode to search for headers:

我有两条路径希望 Xcode 搜索标头:

"/myproject/lib1/include"
"/myproject/lib2/include"

"/myproject/lib1/include"
"/myproject/lib2/include"

What's the correct syntax for adding those two paths inside Xcode's User Header Search Paths? I tried "/myproject/lib1/include";"/myproject/lib2/include"

在 Xcode 的 User Header Search Paths 中添加这两个路径的正确语法是什么?我试过 "/myproject/lib1/include";"/myproject/lib2/include"

But it didn't work. It complained that object1.h not found. object1 is inside /myproject/lib1/include

但它没有用。它抱怨找不到 object1.h。object1 在 /myproject/lib1/include 里面

I already added the whole /myproject/lib1/include folder and /myproject/lib2/include folder into the target project.

我已经将整个 /myproject/lib1/include 文件夹和 /myproject/lib2/include 文件夹添加到目标项目中。

回答by Abizern

Dd you actually put the leading /into the path? Because that's an absolute path and probably not what you mean.

你真的把前导 / 放到了路径中吗?因为那是绝对路径,可能不是您的意思。

You can pass it the relative location using $(SRCROOT)which expands the the directory containing the Xcode project file.

您可以将相对位置传递给它,使用$(SRCROOT)它展开包含 Xcode 项目文件的目录。

So, assuming your project file is in the myrojectdirectory you should put this in your header search paths:

因此,假设您的项目文件在myroject目录中,您应该将其放在标题搜索路径中:

$(SRCROOT)/lib1/include
$(SRCROOT)/lib2/include

回答by Kunal Khanna

Suppose you want to use your project directory, then you should use:

假设你想使用你的项目目录,那么你应该使用:

"$PROJECT_DIR" 

Double quotes are advised if your project path has spaces.

如果您的项目路径有空格,建议使用双引号。

Enable recursive if you want to search within the folders as well. Alternatively, you can use "$(SRCROOT)"

如果您还想在文件夹内搜索,请启用递归。或者,您可以使用"$(SRCROOT)"

回答by user2851386

If you have multiple header paths, use SPACE to divide them, or double click the input text box of header pathS for advance setting. Another recommended way is search "User Header Search Paths" in your Xcode help menu.

如果您有多个标题路径,请使用空格分隔它们,或双击标题路径S的输入文本框进行高级设置。另一种推荐的方法是在 Xcode 帮助菜单中搜索“用户标题搜索路径”。

回答by user2095177

Xcode 6.1.1 also requires you to set Search Paths->Always Search User Paths to 'Yes' ... and have User Header Search Paths as specified in above posts.

Xcode 6.1.1 还要求您将 Search Paths->Always Search User Paths 设置为 'Yes' ... 并具有上述帖子中指定的用户标题搜索路径。