Monday, January 11, 2010

iPhone PrivateHeaders

Purpose:

Apple intentionally restricts the access to certain functions of iPhone OS, such as accessing SMS database, by developers using the public SDK for some reasons. However, developing an application which accesses those functions is not impossible because only the header files of those functions are missing in the SDK (The framework in the SDK actually includes those functions). As a result, some developers use some tool to dump those "private headers" from the private framework. Using the dumped headers and the private framework in the SDK, one can develop iPhone application as powerful as Apple can.

Although including the private headers will be much more powerful than using the public header alone, there are other concerns while using private headers. First, there is nearly no information about using private header found on the web. You may be able to find simple tutorials which teach you how to setup a simple project, but to the best of our knowledge, no detailed information like the usage of each function is found (possibly due to the legal concerns of using private headers). In other words, it is like searching in a dark room while trying those headers. Second, since it is like breaking the restrictions set by Apple if you use private header in your application and Apple will examine every piece of application submitted to Apple store, an application which uses private header will certainly not be allowed to be legitimately signed and be published on Apple store. As a result, your application can only run on a jail-broken device.

Preliminaries:

(Here, we assume readers are using OSX and have installed the official iPhone SDK)
You need a tool called "class-dump-z" to dump the required headers from the private framework. Author has tried "class-dump" and "class-dump-x" but the dumped files are worst than the files dumped by "class-dump-z". However, it seems that "class-dump-z" crashes while running on OSX 10.5 Leopard. If you found it crashes on your OSX 10.5 machine, we suggest you try it on a OSX 10.6 machine (like we did, and it runs perfectly on it). Although "class-dump-z" gives us the best result among the tools we tried, the dumped headers cannot be used directly. Some naming conventions and paths must be fixed before using them. Those information can be found on web or by trial and error (mainly fixing the include header's path and name).

Installing Your Application on a Jail-broken Device:

After building your own application, you need to install your application on a (jail-broken) device. If you do not want to do it through Xcode, you may try an unofficial way. As suggested in this site, you can install your application on a jail-broken device via SSH (Sure you have to install OpenSSH package on your device first). The default root password of the jail-broken device is alpine.