views:

524

answers:

2

I haven't found a comprehensive list of the steps that are required to use a private API from the iPhone Library.

In particular, I would like to know how to get header files, if they are even required, how to get it to compile (when I simply add the header, it complains that the functions aren't defined), and what resources one can use to learn about private APIs (e.g. from other user's experiences, such as http://iphonedevwiki.net/ which has a few).

I've read in other places that people recommend using class-dump to get the headers. Are there any alternative methods? I've noticed that there are some repositories of iPhone Private SDKs, what are the most up to date resources you would recommend?

Most of the previous questions about documentation of private APIs, have all linked to Erica Sadun's website, which doesn't seem to have documentation anymore (all the links on the left are crossed out).

Please save the comments about not using private API's... I know of the biggest risks:

  • App will get rejected by Apple.
  • App will break in future updates to the OS.

I'm talking about legitimate uses, such as:

  • Private application use (e.g. for unit testing, or messing around to see what's possible)
+1  A: 

Objective-C has enough information in the compiled binary to almost completely reconstruct the headers. The only things missing are argument names, which can often be approximated from the type or method prototype, and some structure and enum definitions. That is why programs like class-dump are the best way to get the headers. They are comprehensive, including every method whether it was in the real header or not, up to date and do not need to be distributed. The other way to get headers is to look in the public version of the same framework, for example WebKit is only private on the iPhone and is otherwise well documented.

If you are interested in things besides Objective-C you pretty much have to do it the old fashioned way, slogging through disassembly to guess function arguments. Once you get a few symbols, search for them and maybe you will find a header someone else has posted. otool is a good place to start.

If you include the headers, be it for Objective-C or C, you must also include the frameworks or libraries the headers declare methods for, just like any other headers. Most of the Objective-C stuff is in a PrivateFrameworks folder right next to the regular Frameworks folder. You can look in the usr/lib folder to find libraries.

Be aware that there are lots of differences between the simulator and the device, so make sure you build headers from the real device. There are also some of methods that you will not have permission to run as a sandboxed app.

drawnonward
A: 

http://aralbalkan.com/2106

syam