iOS2011. 10. 26. 21:51

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:

  1. First off, you're going to need the header files for the private frameworks. To dump them, use theFramework Dump Kit from Erica Sadun's site. Download the DumpFrameworks Perl script anywhere and put theclass-dump binary somewhere on your path (I put it in /usr/local/bin/)
  2. Run DumpFrameworks (navigate to the folder you downloaded it to in Terminal and type./DumpFrameworks). This will create the headers in~/Headers.
  3. 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.
  4. 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_namespaceand -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.
  5. 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 theSomeHeader.h: No such file or directory messages and remove the import statements corresponding to those errors from the private header files.
  6. 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.

Posted by 삼스

댓글을 달아 주세요

  1. 눈을 감아봐 입가에 미소가 떠오르면 네가 사랑하는 그 사람이 널 사랑하고 있는거야.

    2013.07.13 02:34 [ ADDR : EDIT/ DEL : REPLY ]
  2. 슬퍼서 우는거 아니야..바람이 불어서 그래..눈이 셔서..

    2013.07.14 12:01 [ ADDR : EDIT/ DEL : REPLY ]
  3. 창밖을 봐 바람에 나뭇가지가 살며시 흔들리면 네가 사랑하는 사람이 널 사랑하고 있는거야.

    2013.07.15 09:15 [ ADDR : EDIT/ DEL : REPLY ]
  4. 지금은 반짝반짝 빛이 나겠지,, 하지만 시간이 흐르면 그빛은 사라저버릴거야,지금 우리처럼

    2013.07.18 05:32 [ ADDR : EDIT/ DEL : REPLY ]