xcode <Cocoa/Cocoa.h> 位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4259837/
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
<Cocoa/Cocoa.h> location
提问by pcmaniac
I am new to Mac OS X development. In XCode/Cocoa developers environment each Objective-C projects starts with#import <Cocoa/Cocoa.h>
It works fine but I am puzzled with Cocoa.h file location. There is no Cocoa.h file in Cocoa folder on my file system. I tried to "find / Cocoa/Cocoa.h" and "locate Cocoa/Cocoa.h" nothing was found.
Can anybody give me a hint on how and where compiler finds Cocoa.h header in above #import statement.
我是 Mac OS X 开发的新手。在 XCode/Cocoa 开发人员环境中,每个 Objective-C 项目都以#import <Cocoa/Cocoa.h>
它开始工作正常,但我对 Cocoa.h 文件位置感到困惑。我的文件系统上的 Cocoa 文件夹中没有 Cocoa.h 文件。我试图“查找/Cocoa/Cocoa.h”和“定位Cocoa/Cocoa.h”什么也没找到。
任何人都可以给我一个关于编译器如何以及在哪里找到 #import 语句中的 Cocoa.h 头文件的提示。
Thanks, Recovering Microsoft Addict
谢谢,恢复 Microsoft Addict
回答by Stephen Furlani
Cocoa/
refers to the /System/Library/Frameworks/Cocoa.framework/Headers/
folder. If you check your project, under "Frameworks" you'll see your included frameworks and cntrl-click to 'reveal in finder' will help.
Cocoa/
指 /System/Library/Frameworks/Cocoa.framework/Headers/
文件夹。如果您检查您的项目,在“框架”下您将看到您包含的框架,按住 cntrl 单击以“在 finder 中显示”会有所帮助。
回答by pcmaniac
I finally found an answer in Xcode Build Setting Referencesection Header-Map Build Settings.
Turned out XCode behind the scene "magically" mapping headers to paths storing info in .hmap files to pass the .hmap files to gcc (compiler).
Environment var HEADERMAP_INCLUDES_FRAMEWORK_ENTRIES_FOR_ALL_PRODUCT_TYPES must be set to use Cocoa/Cocoa.h syntax in #import statements.
And no, Finder does not show .hmap files - use Terminal commands to get them.
我终于在Xcode Build Setting Reference部分的 Header-Map Build Settings 中找到了答案。
原来 XCode 在幕后“神奇地”将标头映射到在 .hmap 文件中存储信息的路径,以将 .hmap 文件传递给 gcc(编译器)。
环境变量 HEADERMAP_INCLUDES_FRAMEWORK_ENTRIES_FOR_ALL_PRODUCT_TYPES 必须设置为在 #import 语句中使用 Cocoa/Cocoa.h 语法。
不,Finder 不显示 .hmap 文件 - 使用终端命令来获取它们。
回答by Wilersh
Spotlight seems to find any header file I have looked for on the system as well.
Spotlight 似乎也找到了我在系统上寻找的任何头文件。