Current location - Quotes Website - Signature design - How Xcode exports developer ipa
How Xcode exports developer ipa
As we all know, the program developed on Xcode can only run on the simulator. If you want to put it on the real machine, you need to spend $99 to buy the developer certificate iDP. This article introduces the demo on the previous generation Xcode4.6.3. Why use the previous generation version? Quite simply, ios7 has not achieved popular jailbreak, so few people use jailbreak ios7 system (except Great God). In order to run Xcode5, since there is no developer certificate and no jailbreak, if you want to run your own ipa file for free on a real machine, only ios7 jailbreak is the only way out. Therefore, without iDP, if you want to debug the program on the iPhone and finally release the ipa for sharing, you need the following steps:

1. Issue a certificate for yourself and sign the generated program;

2. Modify the configuration files and binary files of engineering configuration and Xcode to prevent their verification and signature;

3. Sign the application with a forged certificate through a custom generation step;

4. Generate ipa files with a little skill;

5. You need to jailbreak the device of your ios6 system and install AppSync of ios4/5/6 through Cydia.

Tools: iphone4 6. 1.2 has been jailbroken perfectly, MacBook Pro 13inch, Xcode4.6.3, plist editor (for editing Plist files).

Officially get down to business:

First, create a certificate.

Open Utility-Keychain Access. Then click Keychain Access-Certificate Assistant-Create Certificate in the menu bar to open the wizard. The first step is more important. You must name the name iPhone Developer, set the type to code signing, and select "Let me override these defaults". There is no need to change the following steps, just click OK and Continue all the time to complete the wizard!

Secondly, modify the configuration file of Xcode.

1. Please press Command+Q to close Xcode completely first.

2. Modify the configuration file:

Follow this path to find SDKSettings.plist and edit it:

/Applications/xcode . app/Contents/Developer/Platforms/iphone OS . platform/Developer/SDKs/iphone OS 6. 1 . SDK/SDK settings . plist

In the following two paragraphs, replace "Yes" with "No".

& ltkey & gtCODE _ SIGNING _ REQUIRED & lt/key & gt;

& lt/string & gt; is</string >

and

& ltkey & gt authorization _ required & lt/key >

& lt/string & gt; is</string >

3. Modify another file as follows:

Follow this path to find Info.plist and edit it:

applications/xcode . app/Contents/Developer/Platforms/iphone OS . platform/info . plist

Modify all XCiPhoneOSCodeSignContext in Info.plist to XCCodeSignContext, which are located under the DefaultProperties branch, OverrideProperties branch and RuntimeRequirements branch respectively.

4. Add files:

After connecting to the Internet, perform the following at the terminal:

Mkdir/applications/xcode.app/contents/developer/iphone authorization.

Cd/applications/xcode.app/contents/developer /iphone authorization

curl-O/iphone/gen _ entitlements . txt

mv gen _ entitlements . txt gen _ entitlements . py

chmod 777 gen_entitlements.py

If there is no Internet connection, you can create an iphoneentitlements folder under the folder/applications/xcode.app/contents/developer, and then manually create a gen_entitlements.py file in this folder and grant it execution permission (command: sudo). The contents of this document are as follows:

#! /usr/bin/env python

Import system

Import structure

if len(sys.argv)! = 3:

Print "Usage:% s appnamedest _ file.xcent"% sys.argv [0]

sys.exit(- 1)

APPNAME = sys.argv[ 1]

DEST = sys.argv[2]

if not DEST.endswith('。 Xml') and notDEST.endswith ('. xcent’):

Print "Destination must be. Xml (for ldid) or. xcent (for codesign) "

sys.exit(- 1)

Right = """

& lt? Xml version =" 1.0 "encoding ="UTF-8"? & gt

& lt! DOCTYPE PLIST PUBLIC "-//Apple//DTD PLIST 1.0//EN " "/DTDs/property list- 1.0 . DTD " & gt;

& ltplist version=" 1.0 " >

& ltdict & gt

& ltkey & gt application identifier & lt/key >

& lt string & gt% s & lt/string & gt;;

& ltkey & gt get task permission & lt/key >

& lttrue/>;

& lt/dict & gt;

& lt/plist & gt;

" " " % APPNAME

F = on (DEST, "w")

if DEST.endswith('。 xcent’):

f . write(" \ xfa \ xde \ x 7 1 \ x 7 1 ")

f . write(struct . pack(' & gt; L', len (right)+8))

F. Write (right)

f.close()

Third, modify the engineering settings (real machine debugging flashback, please look at this step carefully, this step is the key issue)

Special note: Before this stage, you only need to modify the configuration file and prepare the script once. But the operation at this stage should be done for every project that needs real machine debugging.

The main function of this step is to support real machine debugging. If you don't do this step, you can still generate ipa to run on the real machine through step 5, but you can't use Xcode's built-in debugger to track the programs running on the real machine in one step. If your program clicks run debugging seconds, please check whether this step is completed correctly.

1. Disable Xcode automatic signature operation.

Set all code signing options in the project configuration to No code signing, as shown in the figure. You may need to click All to display this option first.

2. Add a customized post-generation script

Add a phase in the construction phase, add the construction phase in the lower right corner, and then click Add Run Script to enter the following script:

export CODESIGN _ ALLOCATE =/Applications/xcode . app/Contents/Developer/Platforms/iphone OS . platform/Developer/usr/bin/CODESIGN _ ALLOCATE

If[" $ {platform name} "= =" iphone OS "]| |[" $ {platform name} "=" iPados "]; then

/Applications/xcode . app/Contents/Developer/iphone entitlements/gen _ entitlements . py " my . company . $ { PROJECT _ NAME } " " $ { build _ PRODUCTS _ DIR }/$ { WRAPPER _ NAME }/$ { PROJECT _ NAME }。 xcent ";

Code sign-f-s "iphone developer"-rights "$ {build _ products _ dir}/$ {wrapper _ name}/$ {project _ name}. xcent " " $ { build _ PRODUCTS _ DIR }/$ { WRAPPER _ NAME }/"

The ship does not bear the loading fee.

As shown in the figure:

Now that the configuration is complete, you can plug in the iPhone, re-select the generation target and test online debugging! If it is the first time to use this device for debugging, please switch the device to development mode in Manager (the small green light on the right side of iPhone lights up).

Fourth, generate IPA files.

If my program is debugged, how can I send it to others? Under normal circumstances, ipa files are exported from Xcode's Organizer, but we don't have a certificate, so the output will produce errors. We can only accomplish this operation with a little skill.

First generate the code as the publishing target, and then open the output folder of the project. Usually this directory starts with the project name/build/products/release-iPhone OS /Users/ user name/library/developer/xcode/derived data/folder. There is a xxx.app file in this directory, which is the generated program. Drag this xxx.app to iTunes, it will appear in the application list, and then drag it out of the iTunes list (for example, drag it to the desktop), and it will become xxx.ipa! Send this. Give ipa to others, and everyone can share this program with you.