Where to find the Objective-C Runtime and Headers?
The docume开发者_运维知识库ntation 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.
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.
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.
Do you have XCode/SDK installed? If not - register at http://developer.apple.com and get them.
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").
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.
精彩评论