IOS study notes 5-Xcode Certificate-Free Real-machine debugging below

Source: Internet
Author: User
Tags key string


There are a lot of articles about xcode Certificate-Free debugging programs on the Internet, but there are many errors and the basics are not introduced.
Therefore, I would like to give a brief summary to facilitate the use of new users:

Background: xcode is an essential development tool for phone and ipad development. The developed programs can run through the iphone and ipad simulators provided by xcode. However, you cannot upload a program to a real device for debugging or running. Developers must purchase a Development Account of $99/year to run and Debug Programs on real machines. This article describes how to crack xcode so that you can debug programs on a real machine without buying a $99 Development Account. Note: The iphone or ipad running the program must be jailbroken, And if developers publish the program on the appstore, they must purchase a development account.

1. Create a personal certificate (use the utility-key string access command to create a personal certificate. The detailed steps are described on the Internet. I will not detail them here ). (Optional steps)
The new personal certificate is not apple-certified and is untrusted. Therefore, xcode cannot use this certificate normally. Therefore, xcode must be cracked. However, after cracking xcode, the use of untrusted pseudocertificates is the same as that without a certificate, so this step is not necessary.

2. modify the configuration file and binary file of Xcode to crack xcode.
This is a crucial step. You can crack xcode so that it does not use a certificate or use a forged certificate to upload and debug ios programs to the iphone.

Make sure that Xcode is disabled. On the command line terminal, copy and paste the following code:


#! /Bin/bash
Cd/Developer/Platforms/iPhoneOS. platform/Developer/Library/Xcode/Plug-ins/iPhoneOS \ Build \ System \ Support. xcplugin/Contents/MacOS/
Dd if = iPhoneOS \ Build \ System \ Support of = working bs = 500 count = 255
Printf "\ x8f \ x2a \ x00 \ x00"> working
Dd if = iPhoneOS \ Build \ System \ Support of = working bs = 1 skip = 127504 seek = 127504
/Bin/mv-n iPhoneOS \ Build \ System \ Support. original
/Bin/mv working iPhoneOS \ Build \ System \ Support
Chmod a + x iPhoneOS \ Build \ System \ Support


The above code modifies the support. xcplugin file.


3. Modify the xcode configuration file
① Cd/Developer/Platforms/iPhoneOS. platform/Developer/SDKs/iPhoneOS4.3.sdk/
Add the following two items:
PROVISIONING_PROFILE_ALLOWED = NO
PROVISIONING_PROFILE_REQUIRED = NO


② Replace some words in the "/Developer/Platforms/iPhoneOS. platform/Info. plist" file:
Replace all "XCiPhoneOSCodeSignContext" with "XCCodeSignContext"


4. Open xcode and modify the configuration of a specific project (this step will be performed every time you create a project)
Enable Xcode-> open your Project-> choose Project> Edit Project Setting from the menu-> select "Build" Panel-> find the Code Signing Identity item, change the value of "Code Signing Identity. Two methods:
1) if you create a forged certificate "iPhone Developer" (the name can be used at will), you can select the name of the certificate you created here.
2) If no certificate is created, select "Don't Code Sign"

5. Create the Code Signing Entitlements file.
Without this file, although the program can be uploaded to the iphone for running, xcode cannot debug the program on the iphone.

There are two methods to establish Code Signing Entitlements:
1) Method 1: Create a script using the script file (Note: I did not succeed in this experiment. I am searching for the cause and the added script is not executed)
① Run after connecting to the Internet
Mkdir/Developer/iphoneentitlements401
Cd/Developer/iphoneentitlements401
Curl-O http://www.alexwhittemore.com/iphone/gen_entitlements.txt
Mv gen_entitlements.txt gen_entitlements.py
Chmod 777 gen_entitlements.py

Note: The name of the newly created directory iphoneentitlements401 can be used as needed. However, you must ensure that the directory names are consistent when using the script files.

② Add a custom generation script
Add a Phase in Build Phases, Add Build Phase in the lower right corner, click Add Run Script, and enter the following Script

Export CODESIGN_ALLOCATE =/Applications/Xcode. app/Contents/Developer/Platforms/iPhone OS. platform/Developer/usr/bin/codesign_allocate
If ["$ {PLATFORM_NAME}" = "iphoneos"] | ["$ {PLATFORM_NAME}" = "ipados"]; then
/Applications/Xcode. app/Contents/Developer/iphoneentitlements/gen_entitlements.py "my. company. $ {PROJECT_NAME} "" $ {BUILT_PRODUCTS_DIR}/$ {WRAPPER_NAME}/$ {PROJECT_NAME }. xcent ";
Codesign-f-s "iPhone Developer" -- entitlements "$ {BUILT_PRODUCTS_DIR}/$ {WRAPPER_NAME}/$ {PROJECT_NAME }. xcent "" $ {BUILT_PRODUCTS_DIR}/$ {WRAPPER_NAME }/"
Fi

2) Method 2: manually add files
① Create an object named Entitlement according to this execution in the project. to open the plist File, open the File Menu and choose New File> iPhone OS> Code Signing> Entitlements. name the file "Entitlements. plist ", and then click 'finish '.

② Open the "Entitlement. plist" file, change the "Can be debugged" attribute value to "YES", and change the "get-task-allow" attribute value to "YES ". (YES by default)

③ Change the value of the Code Signing Entitlements item to the newly created "Entitlements. plist ".

After the above five steps, you can go to the iphone without a certificate and debug the program.

This is my summary. Please correct your criticism.

Appendix 1: generate the IPA file (I have not tested it)
If my program has been debugged, how can I send it to others? Under normal circumstances, the IPA file is output from Xcode's Organizer, but we do not have a certificate, so the output will produce an error. We can only use a small Trick to complete this operation.


First generate the Code as the Release target, and then open the project Output Folder. Normally, this directory is
/Users/your username/Library/Developer/Xcode/DerivedData/folder prefixed by project name/Build/Products/Release-iphoneos
This directory contains a. app file, which is the generated program. Put this. drag the app to iTunes and it will appear in the app list. Then drag it out of the iTunes list (for example, drag it to the desktop. ipa.

Appendix 2: specific content of gen_entitlements.py


#! /Usr/bin/env python
Import sys
Import struct
If len (sys. argv )! = 3:
Print "Usage: % s appname dest_file.xcent" % sys. argv [0]
Sys. exit (-1)
APPNAME = sys. argv [1]
DEST = sys. argv [2]
If not DEST. endswith ('. xml') and not DEST. endswith ('. xcent '):
Print "Dest must be. xml (for ldid) or. xcent (for codesign )"
Sys. exit (-1)
Entitlements = """
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE plist PUBLIC "-// Apple // dtd plist 1.0 // EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<Plist version = "1.0">
<Dict>
<Key> application-identifier </key>
<String> % s </string>
<Key> get-task-allow </key>
<True/>
</Dict>
</Plist>
"% APPNAME
F = open (DEST, 'w ')
If DEST. endswith ('. xcent '):
F. write ("\ xfa \ xde \ x71 \ x71 ")
F. write (struct. pack ('> l', len (entitlements) + 8 ))
F. write (entitlements)
F. close ()

 

Related Article

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.