XCode6.0 iOS certificate-free real machine testing method (valid for both MAC and Hackintosh)

XCode6.0 iOS certificate-free real machine testing method (valid for both MAC and Hackintosh)

[[121733]]

Currently, iOS programs developed on XCode can only run in the simulator. If you want to test them on a real device, you need an Apple-certified developer account and purchase a developer certificate iDP, which costs $99 a year!

As a novice who just started learning iOS programming, it really hurts to spend such a large amount of money... After a lot of trouble, and referring to the posts of various masters, I finally succeeded in compiling and running it on a real machine!

I will share the method with you here.

My operating environment is: [Computer] XCode6.0.1 + OS X 10.9.5 [Real iPod Touch] iOS6.1

Preparation:

1. First, you need to have a jailbroken iPhone/iPod/iPad. The jailbreaking method is not provided here.

2. Add the source http://apt.weiphone.com to the Cydia of the real device used for testing, and download AppSync suitable for the system version of the real device.

3. Create a certificate on your computer to sign the generated program.

Create a certificate

The process of creating a certificate is relatively simple. Open "Others-Keychain Access" on your computer. Then click "Keychain Access-Certificate Assistant-Create Certificate..." in the menu bar to open the wizard. Pay attention to the three places here. You must name it iPhone Developer, set the type to code signing, and select "Let me override these defaults". You don't need to change anything in the subsequent steps. Click "OK" and "Continue" all the way to complete the wizard.

4. If Xcode is running, press Command+Q to completely close it. Then open "Others-Terminal". We need to use some UNIX commands, which may seem cumbersome, but believe me, this saves $99 per year!

① Enter the iPhone SDK directory, the instructions are as follows:

  1. cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/

Note: Different versions of Xcode*** have different version numbers. In Xcode 6.0, it is iPhoneOS8.0.sdk. Future versions may have higher versions, and earlier versions may have lower versions. Please change it according to the actual situation. (If you really don't know your version number, you can use the "ls" command to view all files.)

② Back up the original file. If the computer has a password, the system will prompt you to enter the password (it will not be displayed after entering, just press Enter)

  1. sudo cp SDKSettings.plist SDKSettings.plist.orig

③ Edit the configuration file SDKSettings.plist

In order to facilitate modification, we can directly open this file with Xcode. First, open the directory where this file is located:

  1. open .

Double-click SDKSettings.plist in the pop-up Finder window. This will launch the Xcode graphical interface. Expand the DefaultProperties branch and change the following ENTITLEMENTS_REQUIRED and CODE_SIGNING_REQUIRED properties to NO.

Note: You may encounter a system prompt [“SDKSettings.plist” is locked for editing…], which is due to file read and write permission issues. The solution is as follows:

First, modify the folder permissions. At this time, we are in the directory iPhoneOS8.0.sdk. If we enter the command "cd .." to return to the parent directory, and "ls -al" to view all files, we will find that the system displays iPhoneOS8.0.sdk -> iPhoneOS.sdk, which means that iPhoneOS8.0.sdk is a shortcut to iPhoneOS.sdk, so the real folder we want to modify is iPhoneOS.sdk. The command is as follows:

  1. sudo chmod -R 777 iPhoneOS.sdk

Then, modify the read and write permissions of all files in the folder:

sudo chmod 777 *

Now double-click to open SDKSettings.plist, and you will find that the properties that could not be modified just now can be modified!

④ Edit another configuration file Info.plist

  1. cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
  2. sudo cp Info.plist Info.plist.orig
  3. open .

Double-click Info.plist in the Finder window that pops up. Change all XCiPhoneOSCodeSignContext to XCCodeSignContext in three places: DefaultProperties, RuntimeRequirements, and OverrideProperties.

Note: Same as step ③, you may encounter permission issues. Just modify the permissions of the Platforms folder and all files in the folder. Follow the same steps as above.

5. Prepare a custom post-generation script (this step needs to be done online)

  1. sudo mkdir /Applications/Xcode.app/Contents/Developer/iphoneentitlements
  2. cd /Applications/Xcode.app/Contents/Developer/iphoneentitlements
  3. sudo curl -O http: //www.alexwhittemore.com/iphone/gen_entitlements.txt  
  4. sudo mv gen_entitlements.txt gen_entitlements.py
  5. sudo chmod 777 gen_entitlements.py

6. Modify project settings

Note: Modifying configuration files and preparing scripts before this stage only needs to be done once. However, the operations in this stage must be done for each project that requires real machine debugging.

① Disable Xcode's automatic signing operation

Set all Code Signing options in the project configuration "Build Settings" to Don't Code Sign, as shown in the figure.

② Add a custom post-build script In Build Phases, click the "+" sign in the upper left corner, add a "New Run Script Phase", and enter the following script:

  1. export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
  2. if [ "${PLATFORM_NAME}" == "iphoneos" ] || [ "${PLATFORM_NAME}" == "ipados" ]; then
  3. /Applications/Xcode.app/Contents/Developer/iphoneentitlements/gen_entitlements.py "my.company.${PROJECT_NAME}"   "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" ;
  4. codesign -f -s "iPhone Developer" --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent"   "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"  
  5. fi

via:LiuLiu's notebook

Now the configuration is complete!!! Connect your iPhone/iPod/iPad, compile and run, and when you see the program running on the real screen, you will have saved $99!!!

I would like to thank the great post for providing a complete guide to Xcode 5 + iOS 7 certificate-free (iDP) real device debugging and generating IPA.

<<:  Those UNIX classics forgotten by the years

>>:  Hammer cuts prices, is sentiment bankrupt?

Recommend

Today, to all the parents at home! Please share "A loving family"

Expert in this article: Yang Jing, PhD in Immunol...

Is the Xiaomi Note top version on sale today worth buying?

At 9:30 am on May 12, the top-end version of Xiao...

5 core elements of event operations in 2021!

Fission was at its craziest in 2018, with many sc...

WeChat group traffic diversion and operation methods!

Nowadays, many people believe that WeChat groups ...