The route Apple would have you take, and the route you should take if you intend on publishing your app all the way to the appstore is buying an Apple Developer Certificate (which costs about 99$ a year). With it you’ll get to develope, test and distribute your apps on the AppStore. You also get access to a whole load of really awesome resources.
BUT……. If you have a jailbroken device AND if you’re like me, then you’ll wanna debug your case studies and demo apps on your iPhone and not shell out the dough till you actually decide to distribute your app
(Lets say its the Indian blood in me that rebels against paying for something that I could get for free). So I’ve decided that I have to share this…
More after the Jump
Ok, I’ve basically used a mixture of 3 HowTo’s in this tutorial. We’re following the steps that Cawas outlined in his reply in StackOverflow. He in turn is following Jason’s and alex’s method. With the third we have the advantage of being able to debug. I’ll mostly just copy Cawas tutorial. However there’s a step at the end that I’ll add that will enable you to test your applications on any device (ie iPhone 3G onwards).
All the green text in this tutorial is to be entired directly into Terminal (of course
)
Create Self-Signed Certificate
First you’ll need to create a self signed certificate and patch your iPhone SDK to allow the use of this certificate:
-
Launch Keychain Access.app. With no items selected, from the Keychain menu select Certificate Assistant, then Create a Certificate.
- Name: iPhone Developer
- Certificate Type: Code Signing
- Let me override defaults: Yes
-
Click ContinueClick Continue
Blank out the Email address field.
- Validity: 3650 days
- Click Continue until complete.You should see ”This root certificate is not trusted”. This is expected.
- Set the iPhone SDK to allow the self-signed certificate to be used :
- sudo /usr/bin/sed -i .bak ‘s/XCiPhoneOSCodeSignContext/XCCodeSignContext/’ /Developer/Platforms/iPhoneOS.platform/Info.plist
- If you have Xcode open, restart it for this change to take effect.
If I’m not mistaken, you don’t need to “Enable Xcode to Build on a JB device”…. As far as I know, after the first part the app should load on your device (even though it may not debug).
Enable Xcode’s to Build on Jailbroken Device
1. For below iOS 5 :
- sudo /usr/bin/sed -i .bak ‘/_REQUIRED/N;s/YES/NO/’ /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/ SDKSettings.plist
Update 2 :
For iOS 5 : Incase you do still want to go through the whole process the code in terminal that you type should be :
- sudo /usr/bin/sed -i .bak ‘/_REQUIRED/N;s/YES/NO/’ /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/SDKSettings.plist
- sudo /usr/bin/sed -i .bak ‘/_REQUIRED/N;s/YES/NO/’ /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/ SDKSettings.plist
4. Conclude the requirement removal through patching Xcode. This means binary editing:
- cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS/
- printf “\xc3\x26\x00\x00″ >> working
- dd if=iPhoneOS\ Build\ System\ Support of=working bs=500 count=255
- /bin/mv -n iPhoneOS\ Build\ System\ Support iPhoneOS\ Build\ System\ Support.original
- /bin/mv working iPhoneOS\ Build\ System\ Support
- chmod a+x iPhoneOS\ Build\ System\ Support

To Enable Debugging :
1. Setting Xcode to code sign with our custom made self-signed certificate (the first how-to). This step can probably be skipped if you don’t want to be able to debug:
- 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
2. Plug your iPhone in and open Xcode. Open Window>Organizer. Select the device from the list on the left hand side, and click “Use for development.” You’ll be prompted for a provisioning website login, click cancel. It’s there to make legitimate provisioning easier, but doesn’t make illegitimate not-provisioning more difficult.
3. Now You have to do this last part for every new project you make. Go to the menu Project > New Build Phase > New Run Script Build Phase. In the window, copy/paste this:
- export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ codesign_allocate
- if [ "${PLATFORM_NAME}" == "iphoneos" ]; then
- /Developer/iphoneentitlements401/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
Make this work on ALL your iPhone devices
- Now, in order to make the app work on all your iOS devices (ie iPhone 3G onwards) you need to do the following for every project.
- XCode 4 automatically sets the projet archietecture to armv7 for every new iOS app created. However, you need to add armv6 to the required architectures list to support iPhone 3G. To do this, open the Target Build Settings and find “Valid Architectures”. Double click on the line and you’ll see a pop-up box appear. Delete the current architectures using the ‘-’ (minus) sign at the bottom and add 2 architectures : armv7 & armv6

- Hit Done. Now do the same in the Project Build Settings in the Project Editor menu. Change the Valid architectures to armv6 and armv7 as shown above.Done !! Now connect your iPhone and run the application on your device
Awesome post! I will keep an on eye on your blog.
Thank you Dion
Every time i try to run the code to Enable Xcode’s to Build on Jailbroken Device, i get this error:
sed: -i may not be used with stdin
-bash: s/YES/NO/: No such file or directory
I am working on IOS 5.0 and i replaced it instead of 4.2if i go via terminal thru the path i can open the p.list via pico, but i don’t know what to replace, could you show me the light please
Thanks in advance
For iOS 5
If I’m not mistaken, you don’t need to “Enable Xcode to Build on a JB device”…. As far as I know, after the first part the app should load on your device (even though it may not jailbreak.
Incase you do still want to go through the whole process the code in terminal that you type should be :
sudo /usr/bin/sed -i .bak ‘/_REQUIRED/N;s/YES/NO/’ /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/SDKSettings.plist
Can you check that and let me know if it works
Hey very cool blog!! Man .. Excellent .. Amazing .. I’ll bookmark your site and take the feeds also…I’m happy to find a lot of useful info here in the post, we need work out more techniques in this regard, thanks for sharing. . . . . .
Hey I am unable to process any command here. The first command here:(sudo /usr/bin/sed -i .bak ‘/_REQUIRED/N;s/YES/NO/’ /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/ SDKSettings.plist ) gives the error sed: 1: “‘/_REQUIRED/N”: invalid command code ?
-bash: s/YES/NO/’: No such file or directory
can you please help ?
Refer my reply to Edgardo Rodriguez (two posts above yours)
that is what you get when you do what u replied to Edgardo Rodriguez… Any other way to make that work? I’m using xCode 4 and iOS 5 jailbroken device (iPhone) Thanks.
Yes that is what you get and that is what you need to do. All the best
Developer folder is in latest Xcode in xcode.app
Thank you man!
is the process same for the ipad as well ???
Never tried it… Why don’t you try and let us know here so that I can update the post with details
sudo /usr/bin/sed -i .bak ‘/_REQUIRED/N;s/YES/NO/’ /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/SDKSettings.plist
Password:
sed: 1: “‘/_REQUIRED/N”: invalid command code ?
-bash: s/YES/NO/’: No such file or directory
getting stuck here could u pls help me out with dis???
Off the top of my head :
1. Your SDK is different from mine.
2. The iPadOS.platform is different from iPhone (?? not sure about this one)
Users/MacBookPro/Library/Developer/Xcode/DerivedData/Quiz_Game-doshnykxfahtwkegjllmbgpnpxwz/Build/Intermediates/Quiz Game.build/Debug-iphoneos/Quiz Game.build/Script-52914725158B5B5F00585385.sh: line 4: /Developer/iphoneentitlements401/gen_entitlements.py: No such file or directory “iPhone: no identity found…..been trying and slogging but i get dis error all the time cud u help me out with dis….
Your gen_entitlements.py file has not been formed.
You’ll have to manually make it
Hello nice blog, I am newbe on ios. how about testing on ipad1 with xcode 3.2 still sme procedure?
thanks
Yes its the same procedure
Great work, well written and well done. Btw, do I need to this same procedure if I have a developer’s license and want to test on a jailbroken iPad 1?
I cant find the certificate assistant in keychain access. I´m running Mountain lion so can it be different?
Please help!
Great post! An alternative for other readers is an automated app available called JailCoder: http://www.jailcoder.tk – It automates this whole process and enables you to restore to original settings when you decide to fog out the $99