About Apple's private API

Source: Internet
Author: User


IntroductionA. Basic Knowledge

In addition to exposing the Api:published API (or the Api:documented API documented in the document), the APIs in the iphone also have two types of APIs: private Api:private API and undisclosed api:unpublished API (or Api:undocumented API that is not documented in the document). The private API refers to the API placed in the Privateframeworks framework, the unlisted API is that although placed in the frameworks framework, but there is no official document in Apple has the use of instructions, code and other records of the API. The latter two APIs are different, according to Apple, the unpublished API is not mature enough, may also change the API, and so on fully formed will become a public API, but the current no commitment to it is that the system version upgrade may be invalidated. The private API is an API that Apple explicitly cannot use. Although there is a difference between the two, it is similar to the specific use method.

two. Specific Introduction

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

using private or non-exposed APIs, you first need to export their corresponding header files, which have declarations 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.

How to use:

In order to use the Class-dump command in any directory, it is recommended that you copy the Class-dump file to the/user/local/bin/directory, and then 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 The data structure and function declaration of the Uikit.framework framework in the frameworks framework in IPHONESIMULATOR3.0.SDK are extracted and placed in the UIKit.h file, after which you can find the declaration of the API and how to use it in this header file. In the same way, you can export the API declarations that you need in that framework.

You can also write the dumpframeworks.pl in Ericasadun (some comments in the file) this file extracts the API header files from the private framework. The use of the method is also the first copy of the Class-dump file to the/user/local/bin/directory, and then in any directory execution./dumpframeworks.pl, and then you will create a headers folder in your home directory, It lists the API header files under the private framework.

2. Using the private API

after exporting the header file declaration of the private API, it is easier to use the method, first include the header file in your project, then import the corresponding framework, and then you can use these private API functions in our code in a way that provides a static library.


three. Additional Instructions

some of the most sophisticated and playful APIs in iphone programming are included in the private API or the unlisted API, although we can use these very good APIs in this way, but there is a risk that there will be changes to the exposed API first, so that in each firmware version, Your code is likely to be interrupted. At the same time, the biggest problem is that programs that use private APIs can't be sold on the App Store. So if we just experience these wonderful APIs in the iphone for fun, that's okay. If you're selling on the App Store for a program, don't move the idea of a private API.

Private API get tools and use

Class-dump

official address: here

This project has open Source: https://github.com/Bluelich/class-dump, you can fork this project to see.


Download from here

Current Latest version is 3.5 , supports 64-bit Intel Core Manager, need at least Mac OS X 10.8 or more system support

    • Class-dump-3.5.dmg
    • Class-dump-3.5.tar.gz
    • class-dump-3.5.tar.bz2

What I'm downloading here is class-dump-3.5.dmg.

Double-click the. dmg file to pull it into the/usr/local/bin directory,

Put the downloaded class-dump into the usr/local/bin. If '/usr/local/bin' Don't know where, you can enter ' under terminalopen-a Finder/usr/local/bin' To open the directory. This allows the Class-dump command to be used at the terminal.


This shows the calculator that comes with the dump system and exports its header file.

The command is as follows:

Class-dump-h/applications/calculator.app-o/users/rio/desktop/calculate\ Heads

Explain:

/applications/calculator.app is the path to the calculator app

/users/rio/desktop/calculate\ heads is the folder path where dump header files are stored

Usage:
Class-dump 3.5 (+ bit) usage:class-dump [options] <mach-o-file> where options is:-A show Inst ance variable offsets-a Show implementation addresses--arch <arch> choose A specific AR Chitecture from a Universal binary (PPC, PPC64, i386, x86_64)-C <regex> only display classes matching RE Gular expression-f <str> Find string in method Name-h generate headers files in cur Rent directory, or directory specified With-o-I sort classes, categories, and protocols by Inheritanc E (overrides-s)-o <dir> output directory used For-h-R recursively expand Framewo Rks and fixed VM shared libraries-s sort classes and categories by Name-s sort met Hods by name-t Suppress header in output, for testing--list-arches list The Arches in the FIL E, then Exit--SDK-ios Specify iOS SDK version (would look in/developer/platforms/iphoneos.platform/developer/sdks/iphoneos<version &GT;.SDK--sdk-mac Specify Mac OS X version (would look IN/DEVELOPER/SDKS/MACOSX&LT;VERSION&GT;.SDK--s Dk-root Specify the full SDK root path (or use--sdk-ios/--sdk-mac for a shortcut)

running the command, you can see that the file has been dump, as follows:


Class-dump is useful, but sometimes we find that class-dump execution fails to get the. h file we want, or the contents of the. h file are encrypted ciphertext. This behavior occurs because the Class-dump action object must be an unencrypted executable file, and the app downloaded from the app Store is signed and encrypted , and the executable is added with a "shell". You can use Appcrackr to come from a shell.

For Appcrackr, please search by yourselves.






About Apple's private API

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.