IPhone private API usage Learning

Source: Internet
Author: User

I. Basic Knowledge


In addition to the published API: published API (or the recorded API: enented API), APIs in the iPhone include private API and undisclosed API: unpublished API (or API not recorded in the document: undocumented API ). Private APIs refer to APIs placed in the privateframeworks framework. undisclosed APIs refer, however, there are no APIs recorded in Apple's official documentation, such as instructions for use and code introduction. The latter two APIs are different. According to Apple, undisclosed APIs are immature and may change, after being fully formed, it will become a public API, but we do not provide a commitment at present, that is, the system version may become invalid after upgrade. Private APIs are clearly unavailable to Apple. Although the two are different, they are similar in specific usage.


Ii. Details


1. Export the header file declaration that generates the private API


When using private or undisclosed APIs, you must first export the corresponding header file and include the declaration of related functions in the header file.


Tools:


Class-dump


Class-dump can extract the corresponding data structure and function declaration from the compiled objective-C binary file.


Usage:


To use the class-dump command in any directory, we recommend that you copy the class-dump file to the/user/local/bin/directory, then you can execute the following command in any directory:


Class-dump/developer/platforms/iphonesimulator. Platform/developer/sdks/iphonesimulator3.0.sdk/system/library/frameworks/uikit. Framework/> uikit. h


The above command can be used to set the uikit in the frameworks framework of iPhone simulator3.0.sdk. the data structure and function declaration of the Framework framework are extracted and placed in uikit. h In this file, you can find the API declaration and usage in this header file. In the same way, you can export the API declaration in the framework you need one by one.


You can also use the dumpframeworks. pl file written by ericasadun to extract all the API header files under the Private framework. First, copy the class-dump file to the/user/local/bin/directory, and then execute it in any directory. /dumpframeworks. pl, then a headers folder will be generated under your home directory, which lists the API header files under the Private framework.


2. Use private APIs


After exporting the header file Declaration of the private API, it is easy to use. First, include the header file in your project, and then import the corresponding framework, then we can use these private API functions in our code in a similar way to provide a static library.


 


Iii. Additional instructions


Some exquisite and interesting APIs in iPhone programming are included in private APIs or undisclosed APIs. Although we can use these very good APIs in this way, however, there is a certain risk in doing so. First, it is possible to change the public API. In this way, your code may be interrupted in each firmware version. At the same time, the biggest problem is that programs using private APIs cannot be sold on the app store. So it's okay if we just try these amazing APIs on the iPhone for fun. If you want to make programs sold on the App Store, do not use the idea of private APIs.



Class-dump-x extract the hidden file class-dump in the private library

This is a command-line utility for examining the objective-C runtime information stored in Mach-O files. it generates declarations for the classes, categories and protocols. this is the same information provided by using 'otool-ov ', but presented as normal
Objective-c Declarations, so it is much more compact and readable.

Why use Class-dump?

It's a great tool for the curious. you can look at the design of closed source applications, frameworks, and bundles. watch the interfaces evolve between releases. experiment with private frameworks, or see what private goodies are hiding in the appkit. learn
About the plugin API lurking in mail. App.

If you find class-dump useful, you can donate to help support its development. Thanks!

Download

Current version: 3.3.3(Universal, 64 and 32 bit)
Requires Mac OS X 10.5 or later.

  • Class-dump-3.3.3.dmg
  • Class-dump-3.3.3.tar.gz
  • Class-dump-3.3.3.tar.bz2

Changes-news

Contact

You can email questions and bug reports to me at class-dump@codethecode.com, or Nygard at gmail.com.

Usage
class-dump 3.3.3 (64 bit)Usage: class-dump [options] <mach-o-file>  where options are:        -a             show instance variable offsets        -A             show implementation addresses        --arch <arch>  choose a specific architecture from a universal binary (ppc, ppc7400, ppc64, i386, x86_64, etc.)        -C <regex>     only display classes matching regular expression        -f <str>       find string in method name        -H             generate header files in current directory, or directory specified with -o        -I             sort classes, categories, and protocols by inheritance (overrides -s)        -o <dir>       output directory used for -H        -r             recursively expand frameworks and fixed VM shared libraries        -s             sort classes and categories by name        -S             sort methods by name        -t             suppress header in output, for testing        --list-arches  list the arches in the file, then exit        --sdk-root     specify the SDK root path (full path, or 4.1, 4.0, 3.2, 10.6, 10.5, 3.1.3, 3.1.2, 3.1)
License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version
2 of the license, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a participant purpose. see the GNU General Public License for more details.

You shoshould have written ed a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, inc ., 675 Mass Ave, Cambridge, MA 02139, USA.

 

 

Class-dump-H/developer/platforms/iphonesimulator. Platform/developer/sdks/iphonesimulator2.1.sdk/system/library/coreservices/Springboard. APP/springboard

-O

~ /Desktop/springboard

 

 

 

 

 

 

 

 

 

 

 

Download: http://ericasadun.com/headerdumpkit/use to put the downloaded class-dump under usr/local/bin. if '/usr/local/bin' doesn't know where it is, enter 'open-a finder/usr/local/bin' under terminal'
To open the directory. remember to use chmod to modify the execution permission for class-dump. for example, to modify class-dump in usr/local/bin, you can switch to the usr/local/bin directory in terminal: chmod 777 class-dump. 2. Set dumpframeworks. put PL in any directory. you also need to modify the execution permission. 3. OK .. now all the preparations have been completed. enter :. /dumpframeworks. PL wait... there will be a heards folder under your home directory. it contains all the private apis under frmeworks and privateframeworks .! This article from: http://blog.csdn.net/diyagoanyhacker/article/details/6760134

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.