Where to find the Objective-C Runtime and Headers?

The documentation says:

/usr/include/objc

However, on my mac there is no such folder anywhere. Or can't I just see these with Finder? If so what Tools do I need to take a lookt at them? I'm just very interested to see these headers. Just for fun.

Upvotes: 4

Views: 1312

Answers (5)

Alexis King
Alexis King

Reputation: 43902

I was having a similar issue on my Mac OS 10.8 machine, so I did a bit of digging through the Xcode files. It would appear that, for reasons I cannot entirely explain, newer versions of Xcode have these file embedded in their packages.

To find them, right click on Xcode.app and select Show Package Contents. Then navigate to the following path:

Xcode.app/Contents/Developer/Platforms

This directory should include three folders, one for Mac OS X, one for iOS, and one for the iPhone simulator. Each contains its own set of header files and resources. As an example, say I chose the Mac OS X platform. The objc headers can be found in this directory:

MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/objc/

As to why they are here and not in /usr/include/objc, I do not know. On a similar Mac machine also running OS X 10.8, I found them in their proper locations. However, this should be a somewhat accurate method of locating them if they are not there.

Upvotes: 1

rein
rein

Reputation: 33465

In Finder, press shift-cmd-G and type /usr/include/objc

Or you could go to the "Go" menu in Finder and select "Go to Folder..."

It's a hidden folder.

Upvotes: 1

outis
outis

Reputation: 77450

The folder exists and is indeed hidden from the Finder. You can show it if you know what you're doing, but it can also lead to problems if you ever accidentally delete or move something in the /usr hierarchy. Instead, use a terminal if you want to read the headers.

You can open objc.h in XCode by jumping to the definition of id, SEL or Class (in a source file, cmd-doubleclick the name or right-click it & choose "Jump to definition"; with id, then click "typedef id").

Upvotes: 0

Dewayne Christensen
Dewayne Christensen

Reputation: 2094

Not sure what "documentation" you're looking at, but the header files for the system frameworks can be found under their containing frameworks at /System/Library/Frameworks. So NSObject.h resides at /System/Library/Frameworks/Foundation.framework/NSObject.h.

Edit: I just checked both my machines (Tiger and Snow Leopard), and they both have /usr/include/objc/ also. So not sure why you don't.

Upvotes: 1

Oleksandr Tymoshenko
Oleksandr Tymoshenko

Reputation: 1340

Do you have XCode/SDK installed? If not - register at http://developer.apple.com and get them.

Upvotes: 0

Related Questions