Private iPhone APIs in XCode for Dummies
Today I had to use a private API while spiking a feature for an iPhone app I'm working on and I ran into a couple of gotchas along the way. There doesn't seem to be a simple step-by-step guide for using private iPhone APIs in XCode, so here's goes:
- First off, you're going to need the header files for the private frameworks. To dump them, use the Framework Dump Kit from Erica Sadun's site. Download the DumpFrameworks Perl script anywhere and put the class-dump binary somewhere on your path (I put it in /usr/local/bin/)
- Run DumpFrameworks (navigate to the folder you downloaded it to in Terminal and type
./DumpFrameworks
). This will create the headers in ~/Headers. - In your XCode project, right-click the Frameworks folder in the Groups & Files panel and select Add → Existing Frameworks. Navigate to the header file(s) you want to add and select them. You should see the headers added to your project.
- Go to Project → Edit Project Settings, click on the Build tab, and scroll down to the Linking section. For the Other Linker Flags property, enter
-force_flat_namespace
and-undefined suppress
(thank you, Ken Ferry). If you forget this, you will get a linker error telling you that the symbols for the private classes you're using could not be found. - Open up the header files you imported into your project and remove the superfluous import statements that the header dumper put there. Usually this is just an unnecessary
#import "NSObject.h"
but there may be others also. If you get errors, look for the SomeHeader.h: No such file or directory messages and remove the import statements corresponding to those errors from the private header files. - Finally, import the private header files, use the classes in your application, build and run!
Of course, whether or not you should use the iPhone private API is another matter (undocumented calls may break at any time, Apple may reject your app, etc.) If you do want to play around with them, however, I hope the above instructions help you to get started without too much pain.
Comments
by Weyert on 2009-04-10 23:29:47
by Aral on 2009-04-11 11:38:09
by Surendra on 2009-05-05 13:42:01
by Surendra on 2009-05-05 13:31:31
by Surendra on 2009-05-05 13:34:03
by 【OS3.0】エリカ様のように非公式APIをリストアップする方法 | iphoneアプリで稼げるのか on 2009-06-14 12:32:57
by Andreas on 2009-09-23 09:23:20
by ScreenSplitr for 3.0 « ScreenSplitr on 2009-12-27 06:37:25
by Leo on 2009-08-10 21:13:46
by EeKay on 2009-10-23 11:06:58
by Aral on 2009-09-24 21:40:50
by Ignacio on 2009-09-29 15:08:10
by Aral on 2009-11-09 14:06:45
by oxylane on 2009-12-29 16:36:19
by Mohammed Sadiq on 2010-03-29 09:54:24
by iPhone开发技巧之环境篇(8)— 使用非公开的API | YIFEIYANG on 2010-03-28 01:30:22
by Mohammed Sadiq on 2010-03-29 12:43:58
by MGN on 2010-04-16 05:28:26
by MGN on 2010-04-16 05:29:11
by Alex on 2010-09-01 04:57:58
by Syam on 2010-09-28 03:09:39
by ugg boots on 2010-12-14 03:44:25
by Sahil on 2011-08-21 08:24:07