UPDATE: There’s a new method for iOS4 but they’re pretty similar anyway.
So it’s been a while, but now that I’m on break again and have some time, I’m doing a bit of iPhone development again. That means I’m going to need to debug on-device (or at least load my app to it to have fun in the real world with my handiwork). This time, the procedure’s a little different though.
Vital stats:
iPhone OS 3.1.2
Xcode version 3.2.1, 64 bit
Mac OSX 10.6.2 Snow Leopard
Let’s do it.
UPDATE: Corrected a problem with the run script build phase: corrected the directory names for the new version and copied the new phase that doesn’t include “resource_rules.plist.”
UPDATE 2: Somehow I forgot the add an identity step. It’s now #1 below. Sorry guys. Also, while this whole thing should apply to iPhoneOS 4, I’m going to officially text it/repost with 4.01 soon.
The Goal: The goal is the same as the last time and the time before that: we want to be able to click “build and go” in Xcode and get the app we’re working on to load to the phone and start up. More than that, we want to be able to DEBUG on the thing!
Abstract: Our methodology is slightly different this time around. This time we’re going to tell Xcode that it doesn’t need to codesign for iPhoneOS targets, then we’re going to tell it don’t codesign for iPhoneOS targets, then we’re going to tell it, well, actually, codesign but do it using our script, not your built in method.
The Process:
- UPDATE: You actually have to do this first. Most of you didn’t have a problem, since you had to do it in previous guides, but some people have gotten stuck here because I somehow managed to leave this out entirely. Sorry: 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.
- Make some Plist adjustments, starting with SDKSettings.plist:
cd /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk
cp SDKSettings.plist SDKSettings.plist.orig
vi SDKSettings.plist
Find
<key>CODE_SIGNING_REQUIRED</key>
<string>YES</string>
and change YES to NO
then find
<key>ENTITLEMENTS_REQUIRED</key>
<string>YES</string>
and change YES to NO again. - Now, move on to the platform Info.plist
cd /Developer/Platforms/iPhoneOS.platform/
cp Info.plist Info.plist.orig
vi Info.plist
Three times, the following appears:
<key>CODE_SIGN_CONTEXT_CLASS</key>
<string>XCiPhoneOSCodeSignContext</string>
Find each occurrence by, in vi, typing the “/” key and CODE_SIGN_CONTEXT (typing / will open a “find” box at the bottom of the window)
Replace the
<string>XCiPhoneOSCodeSignContext</string>
with
<string>XCCodeSignContext</string>
- And now the real bad boy, some binary patching of Xcode:
cd ~/Desktop
vi script
hit the “i” key and copy/paste:
#!/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 "\xc3\x26\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 the keys, in order: “:” “x” “enter”
chmod 777 script
./script
If it works right, you should see something like
255+0 records in
255+0 records out
127500 bytes transferred in 0.020355 secs (6263821 bytes/sec)
189216+0 records in
189216+0 records out
189216 bytes transferred in 1.200354 secs (157633 bytes/sec)
At this point, you’re done telling Xcode it doesn’t need to codesign. Now, we tell it don’t codesign:
- With a new project open and ready to go (presumably you want to debug this one, though once you change these settings once, they’ll persist from project to project) open Project>Edit Project Settings (from the menu).
Find “Code Signing Identity” and its child “Any iPhoneOS Device” in the list, and set both to the entry “don’t code sign”Now you’ve told Xcode “don’t codesign”
- The final step is to tell Xcode “well, actually you should codesign.”
mkdir /Developer/iphoneentitlements312
cd /Developer/iphoneentitlements312
curl -O http://www.alexwhittemore.com/iphone/gen_entitlements.txt
mv gen_entitlements.txt gen_entitlements.py
chmod 777 gen_entitlements.py
Now you’re good to go! But there’s just one last thing. 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
export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
if [ "${PLATFORM_NAME}" == "iphoneos" ]; then
/Developer/iphoneentitlements312/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
That will call the script you just downloaded in step 5 to sign our app with a fake signature. This is important only for debugging. If you do build and go otherwise (in debug build mode) the app will load onto the phone, and will launch and run manually just fine. However, if the debugger tries to launch it then attach to the process (as when build and go is clicked), the app will segfault and die, causing the error
Error from debugger: The program being debugged is not being run
Perhaps the most confusing part about this error is that build and go works fine up until that point WITHOUT disabling regular code signature! If you sign with a fake identity like we used to in the previous tutorials, everything installs fine, but the legit CODESIGN generated signatures cause the segfault, whereas the gen_entitlements.py ones don’t. To further confuse, the regular CODESIGN in this version of Xcode happens last in the build process, wheras it used to be that the custom run script phase happened last before. Meaning we have to kill legit codesigning or it wipes out our fake codesigning. All one monster headache.
But that should do it. Take all those steps and you should be home free for JBDev without paying $99.
Oh right, except the one last (critical) part. You have to have a jailbroken iPhone, and it has to have Installd Patch installed! That part’s critical. You can find Installd Patch in the iphone.org.hk repo at http://iphone.org.hk/apt, if you don’t have it installed.
CREDITS: Once again, credit for this process goes to various posters in this forum thread at iphonedevsdk.com. All of these steps are there somewhere, it just took a while to re piece them together in the right combination.
Thanks for the tutorial!Everything works!
[…] basado en este tutorial. […]
This can be a big difference, but I tried your instruction on a Leopard with XCode 3.1.4 (still the same iPhone 3.1.2) and everything seems to be fine except the last line of the script of build phase.
codesign -f -s “iPhone Developer” –entitlements “${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent” “${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/”
This is failing with an error:
.: object file format invalid or unsuitable
Now.. I am assuming that’s complaining about the xcent file that your gen_entitlements.py is generating. Do you know what is causing this problem?
Hi Alex, i am always getting this error:
No provisioned iPhone OS Device is connected…
What´s Wrong, i´m developing on Xcode 3.2.1, snow 10.6.2 and iPhone OS 3.1.3…
I am stuck at step 3. Ounce I hit “i” and copy and paste the text do I type in “:x” and hit enter because it doesn’t do anything. The — INSERT — text still stays at the bottom of the terminal window.
Hi Austin, for the 😡 and enter part, press escape before doing 😡 and pressing enter.
I am stuck at step 3 anyways, after doing ./script, it says:
dd: working: Permission denied
./script: line 4: working: Permission denied
dd: working: Permission denied
mv: rename iPhoneOS Build System Support to iPhoneOS Build System Support.original: Permission denied
mv: working: No such file or directory
How can i make it work? Thanks for the help
Hi,
I’m getting an error, that code signing is required, when I try to build app.
Or I shouldn’t select “iPhone device 3.1.3 SDK” and keep to “iPhone simulator” from menu?
@Jean-Sebastien
put “sudo” in front your command in terminal.
eg. “sudo ./script”
It’ll elevate your rights.
@lall
i’m still getting the “code signing is required” error too. wonder what i’m doing wrong…
Hi got it to work on mi dell mini 10v (osx) made two errors first i have selected the wrong sdk in xcode so i got error “must sign the build” then i got “cert is not valid… expierd” but i had not downloaded the “installd patch” with cyydia but after that it worked
[…] оригинал тут […]
Has anyone received this error when compiling? thanks in advance!
iPhone developer: no identity found. Command /bin/sh failed with exit code 1.
Create selfsigned certificate with this name iPhone Developer ,you have instructions on “apple iphone site” for developers-
Great guide! Thnx a lot!
Worked like charm for me with XCode 3.2.1 and iPhoneOS 3.1.3
I’m having the same problem as Frank, : object file format invalid or unsuitable
I’m on OSX Leopard and XCode 3.1.4
i use Xcode 3.1.4 and Leopard 10.5.8
i got “object file format invalid or unsuitable” when script called.
Could you please help me on this?
Thanks,
Sarat W
I also get “object file format invalid or unsuitable”
with Xcode 3.2.1 on Snow Leopard (10.6.3), iPhone SDK 3.1.3
Any chance to update this method for the 3.2 SDK + 3.2.2 XCode?
Perfect! Thanks a lot, Alex. Worked for 64-bit Xcode 3.2.1 and iPhone OS 3.0 (Debug).
As pero mentioned, you might want to mention in these instructions that you also need to create a self-signed certificate with the iPhone Developer name to get things to work.
Sweet Alex, thank you very much!
Worked like a charm wiith Snow Leopard (10.6.3), 64-bit XCode 3.2.1 and iPhone OS 3.1.2
I still get that “Error launching remote program: failed to get the task for process”
but anyway the point is that I can successfully run my app!
Thanks, take care.
I’m getting “Could not translate messages from device”
I’m also getting the error “Could not translate message from device”. In Console i see:
Wed Apr 14 16:45:42 unknown mobile_installationd[146] : developer cert trust result = 5
Wed Apr 14 16:45:42 unknown mobile_installationd[146] : 00808600 load_container_state: Could not lookup application in the install map
Wed Apr 14 16:45:42 unknown mobile_installationd[146] : 00808600 install_application: Could not load container state of original bundle
Wed Apr 14 16:45:42 unknown mobile_installationd[146] : 00808600 handle_install: API failed
Wed Apr 14 16:45:42 unknown mobile_installation_proxy[145] : handle_install: Installation failed
Using Xcode 3.2.2 on iPhone 3G 3.1.2
Does it works with latest version ?
Xcode 3.2.2 iPhone SDK 3.2
It does not work with 3.2.2 same error here
[…] lupa install “Mobile substrate” dari saurik), untuk SDK 3.1.3 target iPhoneOS 3.0 lihat di sini. untuk XCode 3.2.2 dengan target iPhoneOS 3.0 device adalah seperti berikut […]
Also works on 3.1.3 with XCode 3.2.3 (pre-release)… I changed the entitlements folder to 313 instead of 312 and the py script to reflect this… but I don’t think you needed to necessarily. Just to point out, the VIM editing steps you gave aren’t very easy to follow for beginners – i.e. you need to press ESC before :x’ing… but I read your tutorial from before and learnt how to from there!
Oh, also, THANKS =D
compiles run fine on simulator and compiles fine for the device, but since i don’t have a iphone i sent de built to a friend that have a jailbreaked iphone and he said it doesn’t work. what could i have done wrong?
Any Help for Xcode 3.2.2, Iphone 3GS 3.1.3 on a spirit JB?
[…] nuove applicazioni ho dovuto cercare un po’ su internet e finalmente ho trovato un bell’articolo che spiega come fare. L’articolo in inglese è orientato per Xcode 3.2.1 ma funziona […]
ops… a pingback =)
However…
@Calumk I followed this article to compile applications with Xcode 3.2.2 for my iPhone 3GS 3.1.3… and all works fine!
The only thing that not works for me, is the debugging with my iPhone… I’m getting “Could not translate messages from device” and I think it depends on the Mac language (I’m italian). In fact, searching on google, the people who talk of this error, aren’t english.
(sorry for my english) =)
I created a script that executes all changes automatically with a few simple steps for Xcode 3.2.2.
Check my post in my web site: http://www.ttech.it/en/article/2010/05/compiling-app-for-iphone-without-provisioning-profile-with-xcode-3-2-2/
ran the above script, and still getting “No provisioned iPhone OS device is connected.”
🙁 any advice?
OHHH 🙂 ok fix is as followed..
In Xcode Window> Organizer> then choose iphone, and click, use for development 🙂
ENJOY!
I can confirm in case anyone isn’t sure – this works fine for iPad development as well. I have Xcode 3.2.2 (1650) on Snow Leopard. I did adjust a few things to make the changes to the correct SDK (i.e. 3.2 instead of 3.1 2), but it all worked fine. Note: You need to install appsync instead of installd on the ipad.
Everything seems to work fine, including debugging.
appsync is also required on iphone 3gs 3.1.3
Use version 3.1 or 3.0, works fine (DONT use 3.2)
Works like a charm. Many thanks!
With credit card in hand, I was ready to pay for ADP membership but it has been a week and still haven’t heard back from Apple. There is demo coming on Wed. Thanks to you I can now show my client what I have done.
Love you man. Hate Apple as much: think differently my rear …
Why is installd patch required?
Hi everybody, i’m a beginner in iPhone developer.
I tried to build a native application, but i got an error like this:
[iPhone developer: no identity found. Command /bin/sh failed with exit code 1.]. Help me! Thanks
Worked on first attempt! Thanks for the great writeup. 🙂
SL 10.6.1 by Hazard running on VirtualBox 3.2.0
Xcode 3.1.4 with iPhoneSDK 3.1.2
App runs on JB iPhone with 3.1.2 OS.
For you guys with the “could not translate messages from the device” error, you already have the app installed on your device. Delete it with ssh, then install via xcode. Worked perfectly for me after that.
Hi guys, everything works for me when i create a new application. But when i want to run my previous xcode apps there is no submenu AnyIphone OS Device in Project settings – Build…
What should i do?
Iphone 3g, 3.1.2
mac os 10.6.2
xcode 3.2.1
Awesome, worked like a charm after creating certificate
OK, so iOS4 is out, with a jailbreak… im gunna try and see if this still works….
hi guys I encounter the same error
[iPhone developer: no identity found. Command /bin/sh failed with exit code 1.].
please help.
I also have the “iPhone developer: no identity found” problem :\
Carlos, You must first create a self signed code signing certificate with that name.
Wow! Thank you so much for this. It all works perfectly.
@Calumk:
Thanks a lot! You saved my brain!