Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac - Adding CoreGraphics.framework, for CG use in a C header

Xcode 3.25, Mac OS X 10.6, 10.5 compatibility required.

I have a Mac Xcode project, which mixes Cocoa and C/C++. Some legacy modules require a C-only header.

I created a C header file: myCTypes.h

I wish to use a CGPoint in that header.

Compiling generates an error: CGPoint is not defined. OK, no problem, so I'll just:

#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.

So I try to add it manually, navigating my way to System/Library/Frameworks. Nup, not in there either.

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.

Can someone please tell me what I'm doing wrong here? What do I need to use CGGraphics in that header? Cheers.

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.)

like image 298
SirRatty Avatar asked Nov 13 '10 01:11

SirRatty


2 Answers

Core Graphics is part of Application Services, so that's the header you should include:

#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.

like image 177
Peter Hosey Avatar answered Nov 15 '22 05:11

Peter Hosey


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.

Click on your project in the project navigation pane; build phases; link binary with libraries. Then, chose coreGraphics; then click add.

Thats all, enjoy.

like image 31
ShacharAngel Avatar answered Nov 15 '22 07:11

ShacharAngel