UPDATE: NEWGUIDE NEWGUIDE NEWGUIDE!
Vital iPhone stats for this post:
iPhone version: 3G (should work with 2G and 3GS)
iPhone OS version: 3.0 (rock the hizzouse!)
Jailbreak status: Jailbroken using Pwnage Tool.
The Goal: Get live on-device XCode debugging without being a paying ADC member. This time OS 3.0 style.
Abstract: Same deal as last round. We want to break code signing on the iPhone, and then we want to make Xcode load software into it automatically to debug. In SDK 2.2 (Xcode version 3.1.2) this was just a simple matter of editing some Plists and such to tell Xcode to ignore provisioning profiles. SDK 3.0 (Xcode version 3.1.3) broke these Plist editing tricks. For a while, all you could do was try to hack SDK 3.0 support into Xcode 3.1.2, installed with SDK 2.2. That was really very hairy, though, if you didn’t want to have to switch environments to debug (close and restart Xcode). It was also annoying to configure. Luckily, there’s a new, much less ghetto way. It’s all based on a little hack posted by <zim> in this thread (coral). Essentially, it just replaces a few bits in the Xcode plugin that actually handles the device build, which restores our build and go ability.
Procedure: things marked (2.2 STEP) will already be done if you followed my previous procedure, and you may not need to repeat them.
- Jailbreak your phone. In Cydia, add the source http://iphone.org.hk/apt/. Install the package “Installd Patch” (this used to be Mobileinstallation Patch, just a name change in OS 3.0). Thanks go to @javacom for this lovely little hack, and lots of other wonderful info on his blog. Seriously, if you’re reading this right now, you should be following him. UPDATE 8/3/09: Some are reporting that if you’re on OS 3.0.1 or possibly a 3GS (or both) Installd Patch may or may not actually install. If this is the case, or if you get weird message about your identity being no longer valid, try installing AppSync as a stand-in.
- (2.2 STEP) You will need a signing identity. We’ll break the check such that it doesn’t have to be an official ADC one, so you can make your own using this guide from apple (coral). What you are doing in this step is creating a “Self-Signing Identity.” Note that you should name the identity “iPhone Developer” EXACTLY to avoid having to change a bunch of the steps below.
- (2.2 STEP) Open your project and go to (menu) Project > Edit Project Settings. In the list of properties, find “Code Signing Identity” > “Any iPhone OS Device” and click in the empty box. Assuming there are no entries in the menu, click “Other” and type in the same name you used to generate the code signing certificate above in step (2). For example: in step 2, I used the name “iPhone Developer” and that is exactly what I put in this field. Hit OK and close that settings window. This setting should persist in future projects, and you shouldn’t have to do this again.
Add the special 3.0 sauce:
- Open a terminal.
- type
cd ~/Desktop
(enter) - type
vi script
(enter) - tap
i
on your keyboard (to enter “insert” mode in vi). - Copy/Paste (cmd-v) the following code into your terminal window:
#!/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 iPhoneOS\ Build\ System\ Support.original
/bin/mv working iPhoneOS\ Build\ System\ Support
chmod a+x iPhoneOS\ Build\ System\ Support - type ESC, then
: x
(colon,x) (enter). This saves and exits in vi. - type
chmod 777 script
(enter) - type
./script
(enter) This will execute the script to patch the Xcode plugin. Assuming it completes correctly, you should be good to go, try it out!
If it executed correctly, you should see something like this:
alex-whittemores-computer:Desktop alex$ ./script
255+0 records in
255+0 records out
127500 bytes transferred in 0.035658 secs (3575647 bytes/sec)
191056+0 records in
191056+0 records out
191056 bytes transferred in 1.782819 secs (107165 bytes/sec)
And the final step (added 7/18/09, fixes the issue where debugging failed on 3.0 and where the binary would fail to launch on 2.2.1): Codesign the binary before it hits the phone (this got patched out in the new Xcode method above). In terminal:
mkdir /Developer/iphoneentitlements30
cd /Developer/iphoneentitlements30
curl -O http://www.alexwhittemore.com/iphone/gen_entitlements.txt
mv gen_entitlements.txt gen_entitlements.py
chmod 777 gen_entitlements.py
Add the build phase: in Xcode, select the menu options “Project > New Build Phase > New Run Script Build Phase”, and enter the following script:
export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate if [ "${PLATFORM_NAME}" == "iphoneos" ]; then /Developer/iphoneentitlements30/gen_entitlements.py "my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent"; codesign -f -s "iPhone developer" --resource-rules "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/ResourceRules.plist" \ --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/" fi
NOTE: You will have to repeat this step for every project! (That is, the add build phase part, not the terminal part.) It’s a bummer, but I’m not sure there’s any way around it. I’ll try to figure out if you can persist custom build phases across projects.
Note: You may notice that a number of the steps you remembered from last time are gone now. I believe the few-byte hack above takes care of all the steps. As far as I know, there’s no need to even modify your projects with that one Plist key, everything just works. I currently have this setup working on my production machine, but just to be sure, I’m going to boot up my external disk and I’m going to test this procedure start to finish. As usual, don’t hesitate to comment if you have questions or run into trouble, and I’ll do my best to help.
Special thanks regarding the last step to zim at iPhone Dev SDK forums and to Sylvain Munaut, whose script gen_entitlements.py is used above.
You need to do step 2 under “procedure” perhaps with ‘developer’ lower-case.
That helped, thanks Alex.
I am getting a new error when Xcode tries to install the app onto the device:
“The identity used to sign the executable is no longer valid.
Please verify that your device’s clock is properly set, and that your signing certificate is not expired.”
Obviously, I checked and all seems to be in order. I rebooted both devices, cleaned the build, still having the same problem. Any thoughts?
I also noticed that there a difference between the patch script in this thread and the one in your 3.1.2 thread
—(3.1.2 thread)
> working
—(this thread)
> printf “\x8f\x2a\x00\x00” >> working
Is the difference critical? and what is the correct one of XCode 3.1.4?
The difference IS critical, since it has to do with the location of the appropriate bits to patch and that changes from xcode 3.1.4 to 3.2.1. This thread should be correct for 3.1.4.
If it’s saying the identity is no longer valid, your best bet is to either check that it’s definitely NOT out of validitiy (keep in mind you can set the START valid date too, maybe it was accidentally set to something in the future and not right when you created it?) and failing that try restarting everything.
Hi Alex,
I’ve followed the steps, but I’m not able to debug on the device. When I click “Build & Go”, I get the error:
“CodeSign error: a valid provisioning profile matching the application’s identifier xxxxx could not be found”
I have XCode 3.1.4 and Developing for 3.2.1.
Thanks for any help!
Same as you Javier!
“CodeSign error: a valid provisioning profile matching the application’s identifier xxxxx could not be found”
i have Xcode 3.2.1 64-bit
well, i did what this says …
… it just crashes. not sure what to do about it…
oops, i mean that xcode crashes. after i switch from simulator to device, and as soon as i do anything else after that.
I’ve got 10.5.8 and Xcode 3.1.4 and have the same issue: Xcode just crashed after switching from Sim to Device.
Process: Xcode [803]
Path: /Developer/Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.Xcode
Version: 3.1.4 (1203)
Build Info: DevToolsIDE-12030000~1
Code Type: X86 (Native)
Parent Process: launchd [124]
Interval Since Last Report: 777 sec
Crashes Since Last Report: 1
Per-App Interval Since Last Report: 461 sec
Per-App Crashes Since Last Report: 1
Date/Time: 2010-02-13 22:35:33.221 +0200
OS Version: Mac OS X 10.5.8 (9L31a)
Report Version: 6
Anonymous UUID: 4D8B9628-D97B-4EF0-8306-E2E3A64A7266
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000001
Crashed Thread: 10
Man, I’m glad to see others with this problem. A couple of times I was able to get it to work by completely removing Xcode and reinstalling, but the problem comes back. When I was a Windows guy I had some utilities I could use to track down problems but I’ve only been using a Mac (actually a Hackintosh) for about a year so don’t know how to go about finding the problem. I hope someone can solve it soon.
Rich
The first project I have tried this, it worked perfectly.
Now with the second project (and when I repeat the steps), it keeps saying:
Code Sign error: a valid provisioning profile matching the application’s Identifier ‘com.yourcompany.name’ could not be found
Any suggestions?
[…] такая же как и для iPhone 3.0 и iPhone 2.2, чтобы иметь возможность компилировать в Xcode […]
guys, please help me, iv got error
Please verify that your device's clock is properly set, and that your signing certificate is not expired.
(0xE8008018)
using 3.14 xcode, 3.1.1 iPhone OS
i can’t install other, so please help me solve this problem
best,
Alex
Hi Alex,
Thanks so much for the post, it is terrific.. I know I am close but I am still having the error that others have mentioned “Code Sign error: a valid provisioning profile matching the application’s identifier ‘com.yourcompany.ProgramName’ could not be found.”
I am using xCode 3.2.1 and this is regardless of any SDK that I compile under (although the person who wrote the code wrote compiled it with 2.2.1) .
In my particular case, someone else has built this code for me on their system using the keychain name “iPhone Developer”, so one would think these steps would be perfect.
However: when I generate a new key I cannot get a trusted key to reside as “iPhone Developer”,it says “this root certificate is not trusted” – I have generated the key several times all with the same result.
Thank you for any assistance you can provide.
Jacq.
wow, it did work!! really. Well for all the people asking, it ONLY works for the SDK 3.0 with XCode 3.1.3, this is the download link from apple http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.0__final/iphone_sdk_3.0__leopard__9m2736__final.dmg the only limitation is that you can only make apps for OS 3.0 or lower (it works for me because I am learning) the only thing and I dont know why is that I dont have to apply the last script for project.
Alex Thank you very much!! This guide was really helpful
For those who are crashing upon selecting Device-3.0|Debug:
For me, I tried getting this to work on xCode 3.1.4, whereas I think this hack only works to ver 3.1.3.
I saw a slightly different output when running the patch script, but thought hey lets see what happens.
Well, crash happens.
Easiest way to back out the changes is to rename the “iPhoneOS Build System Support.original” back to “iPhoneOS Build System Support” which replaces the patched version with the original.
so just:
cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS Build System Support.xcplugin/Contents/MacOS
then:
mv iPhoneOS Build System Support.original iPhoneOS Build System Support
easier than reinstalling the whole SDK, right?
unfortunately we still have to figure out how to get the code built…
[…] launch on the device. It's come down to considering these two guides, which look pretty reliable: Developing for a jailbroken iPhone, A to Z (iPhone 3.0) | alexwhittemore.com Developing for a Jailbroken iPhone A to Z (iPhone 3.1.2) | alexwhittemore.com I AM CURRENTLY […]
>For me, I tried getting this to work on xCode 3.1.4, whereas I think this hack only works to ver
>3.1.3.
I had 3.1.4 installed and was crashing as others reported, googling turned up this…
\xc3\x26\x00\x00 instead of \x8f\x2a\x00\x00 in the script does the trick for device debugging for me.
Thank you popinsky this worked for me
Does this work for xcode 3.2.3?
does this work for iOS 4.1 SDK?
After I executed all steps, I can get the result and run the program on my iphone4. But, how to pack the program as a ipa format?
[…] Developing for a jailbroken iPhone, A to Z (iPhone 3.0 … ← Paper Wings Review » 148Apps » iPhone and iPod Touch […]
hey, im penitential throughout being noob, i faith i set the licence subforum to dispatch to my introduction thread. Im 27yo and im here to find some interesting informations! faith to remain throughout pro a extensive time and to abut you guys! http://www.filmovita.com/pic/images/50801767783208591711_thumb.png