XCode 包含路径

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

XCode include paths

xcodeincludepath

提问by bleater

I'm having a problem getting XCode to deal with a particular file structure that I am using or that I wish to use.

我在让 XCode 处理我正在使用或希望使用的特定文件结构时遇到问题。

I have a set of files in the following form...

我有以下格式的一组文件...

Library
   Headers
      Library
         Package1
            Header1.h
            Header2.h
            HeaderN.h 
         Package2
            Header1.h
            Header2.h
            HeaderN.h 
         PackageN
            Header1.h
            Header2.h
            HeaderN.h 
   Source
      Package1
         Source1.m
         Source2.m
         SourceN.m 
      Package2
         Source1.m
         Source2.m
         SourceN.m 
      Package3
         Source1.m
         Source2.m
         SourceN.m 

The include model I want for code outside of this library is...

我想要的这个库之外的代码的包含模型是......

#import "Library/Package/Header.h"

I want to point XCode at Library/Headers but not at the internal folders. When I add this tree to the project XCode seems to make implicit include paths to every node in the tree.

我想将 XCode 指向库/标题而不是内部文件夹。当我将此树添加到项目中时,XCode 似乎隐式包含树中每个节点的路径。

Client code within the project but outside this tree can do this...

项目内但在此树外的客户端代码可以执行此操作...

#import "Header.h"

instead of...

代替...

#import "Library/Package/Header.h"

I can't seem to find a way to dissallow the non-qualified form.

我似乎无法找到禁止不合格表格的方法。

Any help would be appreciated.

任何帮助,将不胜感激。

Thanks, -Roman

谢谢,-罗马

采纳答案by fbrereto

If you include the headers in files in the project then XCode will always find them without path qualification, as you've discovered. The best solution is to remove the headers from the project and specify "Library/Headers" as a header search path in your project settings. The headers won't show in your project, but they also won't be implicitly found by XCode while compiling, either; client code will have to specify the full path off of "Library/Headers" to get to the header file they want.

如果您在项目的文件中包含头文件,那么 XCode 将始终在没有路径限定的情况下找到它们,正如您所发现的。最好的解决方案是从项目中删除标题并在项目设置中指定“库/标题”作为标题搜索路径。标题不会显示在您的项目中,但在编译时也不会被 XCode 隐式找到;客户端代码必须指定“库/标题”的完整路径才能到达他们想要的头文件。

回答by bleater

You're running up against Xcode's behaviour that it builds a flat-headermap. You can disable this by adding the build setting:

您遇到了 Xcode 构建平面头映射的行为。您可以通过添加构建设置来禁用它:

HEADERMAP_INCLUDES_FLAT_ENTRIES_FOR_TARGET_BEING_BUILT=NO

to your project settings.

到您的项目设置。