xcode Mac - 添加 CoreGraphics.framework,用于 C 头文件中的 CG
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4170459/
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
Mac - Adding CoreGraphics.framework, for CG use in a C header
提问by SirRatty
Xcode 3.25, Mac OS X 10.6, 10.5 compatibility required.
需要 Xcode 3.25、Mac OS X 10.6、10.5 兼容性。
I have a Mac Xcode project, which mixes Cocoa and C/C++. Some legacy modules require a C-only header.
我有一个 Mac Xcode 项目,它混合了 Cocoa 和 C/C++。一些遗留模块需要一个 C-only 头文件。
I created a C header file: myCTypes.h
我创建了一个 C 头文件:myCTypes.h
I wish to use a CGPoint in that header.
我希望在该标题中使用 CGPoint。
Compiling generates an error: CGPoint is not defined. OK, no problem, so I'll just:
编译产生错误:CGPoint 未定义。好的,没问题,所以我只会:
#include: "<CoreGraphics/CoreGraphics.h>"
Unfortunately, I get this:
不幸的是,我得到了这个:
error: CoreGraphics/CoreGraphics.h: No such file or directory
Hmm. OK, so I'd best add the framework. But if I right-click on the frameworks group within Xcode, and try to "Add an existing framework", CoreGraphics does not show up in the list. Grr.
唔。好的,所以我最好添加框架。但是,如果我右键单击 Xcode 中的框架组,并尝试“添加现有框架”,则 CoreGraphics 不会显示在列表中。咕噜噜
So I try to add it manually, navigating my way to System/Library/Frameworks. Nup, not in there either.
所以我尝试手动添加它,导航到系统/库/框架。Nup,也不在那里。
So I look in the 10.5 SDK paths, and once again, there's a lot of CoreXXX frameworks in there, but no CoreGraphics.framework.
所以我查看了 10.5 SDK 路径,再次发现里面有很多 CoreXXX 框架,但没有 CoreGraphics.framework。
Can someone please tell me what I'm doing wrong here? What do I need to use CGGraphics in that header? Cheers.
有人可以告诉我我在这里做错了什么吗?在该标题中使用 CGGraphics 需要什么?干杯。
EDIT
编辑
This was solved by:
这是通过以下方式解决的:
#include <Carbon/Carbon.h>
(But if anyone wants to tell me if this is good practice or not, please feel free. Cheers.)
(但如果有人想告诉我这是否是好的做法,请随意。干杯。)
回答by Peter Hosey
Core Graphics is part of Application Services, so that's the header you should include:
Core Graphics 是应用程序服务的一部分,所以这是您应该包括的标题:
#include <ApplicationServices/ApplicationServices.h>
You can include Carbon.h if you want, but its total length after preprocessing is very long, so you should include it only when you absolutely have to (e.g., for Carbon Events hotkey stuff) in order to keep your build times down.
如果需要,您可以包含 Carbon.h,但其预处理后的总长度非常长,因此您应该仅在您绝对必须(例如,对于 Carbon Events 热键内容)时才包含它,以缩短构建时间。
回答by ShacharAngel
Well i know this topic is super old but i wanted to answer pqnet`s question in the comments (can't comment on it because I have less than 50 rep points :( ) now to the point: Yes, today anyway, you can add only core graphics framework if you like.
好吧,我知道这个话题太老了,但我想在评论中回答 pqnet 的问题(无法对此发表评论,因为我的代表点数不到 50 :()现在重点:是的,无论如何,今天你可以如果你愿意,只添加核心图形框架。
Click on your project in the project navigation pane; build phases; link binary with libraries. Then, chose coreGraphics; then click add.
在项目导航窗格中单击您的项目;构建阶段;将二进制文件与库链接。然后,选择coreGraphics;然后点击添加。
Thats all, enjoy.
就这些,尽情享受吧。