Vital Stats:
iOS 4.0.1
Xcode 3.2.3
Mac OSX 10.6.4 Snow Leopard
iPhones 3G, 3GS, 4 (I finally have the whole lineup!)
PROBLEM: I still can’t get iPhone 4 working. If you have one, please try it and help me out! UPDATE: Found the cause of the problem to be certain status bar libraries installed alongside other apps. I’m not sure why they cause the problem, but see full notes at the bottom of the post.
The Goal: As usual, 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. Also, we want to be able to debug from within Xcode itself. After all, Xcode is cool, and terminal+makefiles+gcc+gdb is lame.
Abstract: The plan remains unchanged from the 3.x method. In fact, you commenters practically wrote this one for me. 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’tcodesign 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: With Xcode closed and your device unplugged from the computer,
- If you’ve done this step before for previous guides, you may ignore it. You’ll need a code signing identity in order to sign code to run on the device. Normally, this would be issued by Apple, but later on we’ll break the signature check so you can make a “Self-Signing Identity” using this guide from apple (coral). Note that you should name the identity “iPhone Developer” EXACTLY to avoid having to change a bunch of the steps below.
- On your jailbroken iPhone, install the app AppSync. Add the source http://cydia.hackulo.us to cydia. You’ll get a warning about pirating software: this patch, by virtue of breaking Apple’s DRM so that we can install our own app, also enables us to install cracked App Store apps. Don’t do that. It’s immoral, fails to support legitimate developers who should be rewarded for their effort, and perhaps above all, pirating $2 cell phone apps is just ultra lame. But since our purposes are not nefarious, dismiss the warning. From this repo, install the package AppSync for OS 4.0, and for good measure, reboot the device.
- Make some Plist adjustments, starting with SDKSettings.plist:
cd /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk sudo cp SDKSettings.plist SDKSettings.plist.orig sudo vi SDKSettings.plist
Find
CODE_SIGNING_REQUIRED YES
and change YES to NO
then findENTITLEMENTS_REQUIRED YES
and change YES to NO again. HINT: in vi, you can type the ‘/’ key in order to “Cmd-F”
- Now, move on to the platform Info.plist
cd /Developer/Platforms/iPhoneOS.platform/ sudo cp Info.plist Info.plist.orig sudo vi Info.plist
Two times, the following appears:
CODE_SIGN_CONTEXT_CLASS XCiPhoneOSCodeSignContext
Find each occurrence and replace the block
XCiPhoneOSCodeSignContext
with
XCCodeSignContext
- 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 /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
$ ./script 223+1 records in 223+1 records out 111648 bytes transferred in 0.002678 secs (41692099 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). Click on the “Build” tab.
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.”
- Almost done: time to tell Xcode “well, actually you should codesign.”
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
-
And finally, to link the device and computer. 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.
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 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
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, the app will load to the phone, but the app will fail to launch and you’ll get:
Error from debugger: The program being debugged is not being run
That should do it. Take all those steps and you should be home free for JBDev without paying $99.
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.
iPhone 4 Issue (UPDATE see below): So the method above has been tested working for my 3G and my 3GS. I don’t have my 2G right with me, but I expect it’s no different from the previous method, given that it can’t run iOS4.
The problem that I run into is this:
[Session started at 2010-08-04 20:35:02 -0400.]
//GDB stuff
Program loaded.
target remote-mobile /tmp/.XcodeGDBRemote-93925-69
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
run
Running…
[Switching to thread 11523]
[Switching to thread 11523]
continue
warning: Unable to read symbols for "/Library/MobileSubstrate/MobileSubstrate.dylib" (file not found).
// A bunch of other lib load warnings like this here...
warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0.1/Symbols/usr/lib/libcrypto.0.9.8.dylib" (file not found).
Debugger stopped.
Program exited with status value:45.
The killer is that the app installs, launches, crashes, and then launches fine manually. But I also can’t connect GDB to the running process after the fact either, GDB claims the process isn’t running. I have no idea what’s going on. Anyone?
UPDATE (8/3/10): Totally by chance I happened to read this article on TUAW today about FaceTime. I didn’t pay much attention until about half way down something caught my eye:
…rather significant My3G bug — when installed, you cannot use your iPhone for native software development….
I had initially thought that maybe third party software was to blame but I meticulously disabled each MobileSubstrate extension I had one at a time and ruled them all out. Turns out that wasn’t good enough. The (since fixed) My3G bug was exactly the source of this issue, but I had actually uninstalled My3G and the problem persisted. The issue, it turns out, is with the status bar library Intelliborn uses in their products, IntelliStatusBarIcons. BUT, it doesn’t stop there. By individually uninstalling apps, I’ve found that Backgrounder (and NOT libstatusbar) also cause a dealbreaking bug. Instead of the program exiting with status:45, the new error is “Program received signal: “SIGUSR1”. at which point the application hangs. Conveniently, the workaround is easy, if annoying: For your particular project title, add an Override in Backgrounder. Hopefully this IS a bug in Backgrounder and not a byproduct of its function. But at least now you can debug again!
So partly I’m dumb and partly this is just a bummer. Full story in this post, but the general idea is that gdb catches a SIGUSR1 from Backgrounder and you have to ‘continue’ through it. And obviously, disabling Backgrounder for your app prevents the signal from getting sent.
Hi,
I updated XCode and the SDK to 4.1.
After that, I completed the steps above and my Macbook (iTunes and XCode Organizer) refuses to detect my iPhone 4.
Anybody encountered this? Suggestions for a fix will be welcome.
Thx in advance,
AL
Thanks for your great work, really appreciated
Followed the guide exactly (for those who dont like vi, just use dashcode)
Works for build .app (with device) then ssh it into /Applications
(gives error -19yyyy, but still works)
Will not build and run, but problem is not related to this code.
OS X 10.6.5
iphone 3G iOS 4.2.1 with pwned ipsw
Xcode 3.2.5 with iOS 4.2 SDK
@those not being able to get green light in organiser, just build app and send it over ssh
@those with indentity problems, dont forget capitalization in iPhone Developer, and dont forget to set id certificate to code signing.
OS X 10.6.5
iphone 3G iOS 4.2.1 with pwned ipsw
Xcode 3.2.5 with iOS 4.2 SDK
when i plug my iphone
IN Organizer
i get a warning :”
unknown ios detected
Xcode does not have debugging information for the version of iOS on the device named “Niko’s iPhone”. Xcode can collect debugging data from the device to enable development with this version of iOS. This process only needs to be done once per iOS version, and will take several minutes. ”
then i select collect
Organize always show that xcode is copying file(2/2)
I purchased Xcode 4.0 thru the Mac App Store. Once I had it installed, I delete the 4.58 GB “Install Xcode” from my /Applications folder. Now the Mac App Store doesn’t recognize that I need the 4.0.1 update. So now, I am in the process of restoring “Install Xcode” from my Time Machine.
Thank you very, very much! After uninstalling AdBlock this worked perfectly on Xcode 4, iPad 4.2.
I’m getting this:
iPhone Developer: this identity cannot be used for signing code
Anyone else run into this?
Hi. i have followed the above steps. but i am getting this error :
Error launching remote program: failed to get the task for process 1085.
The program being debugged is not being run.
I get this error when i run my project on device only. i am not able to use the debugger for device.
i have also written the run script for the project.
i have followed all the steps which u stated. but the debugger is simply not working. plz help me , i have been banging my head for 3 days but with no result.
Never worked to me even in Xcode 3.2.x, not working now on XCode 4.On XCode 4.1 (for mac 10.7) and it compiles, but I can’t find the app on the iPod nor in any folder on mac. I have an iPod 3G and I am SURE of not having done nothing wrong.
Edit: since my ipod has 4.0 and XCode can build only with iOS 4.2, I guess this is the reason it does not install. Anyway I’d like to ask about these errors:
“Warning: Application failed codesign verification. The signature was invalid, or it was not signed with an Apple submission certificate. (-19011)
Warning: This bundle is invalid. The application-identifier entitlement is not formatted correctly; it should contain your 10-character App ID Seed, followed by a dot, followed by your bundle identifier: my.company.Test (-19053)
”
I guess the app has been compiled, since I get only warnings, still I’d like to know where are the binaries.
What I have to say…. This trick works perfect with XCode 3.2.5
And then I was wondering if it will work with XCode 4 FINAL, after trying it worked perfectly!!!
Mac OS 10.6.7 hackintosh
XCode 4 final
iPad and iPhone connected as developer device.
all working fine.
debugger working too.
thx 4 that solution.
Thank you!
I got everything working with my iPod touch gen 4 with iOS 4.1. The last step for me was to change the project format from 3.1 to 3.2 before the debugger would work.
Just tried this with Xcode 4.0.1, IOS 4.3.1, JB’d with the new untether from iPhone Dev Team and it works a charm.
Great guide!
@Scott – Same here. Have the latest build of Xcode as well as the newest JB for 4.3.1 and this guide worked flawlessly.
I’m somewhat lost at the last step, however, the old instructions state “Go to the menu Project > New Build Phase > New Run Script Build Phase”. The menu hierarchy for Xcode 4 is completely different, and none of that applies. How can I go about executing that script in Xcode 4?
I have XCode 4.0.1, JB Touch 4.3.1, I’ve followed the steps, except when I try to run the application I’m getting the below error:
iPhone Developer: no identity found
Command /bin/sh failed with exit code 1
Any ideas why?
Thanks
The above error was because the certificate was not signed with “iPhone Developer”..
Now, I”m getting:
“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”
Got it all working on latest Xcode + Jailbreak.
Only steps that differ from before:
Old Xcode – “Go to the menu Project > New Build Phase > New Run Script Build Phase”
New Xcode – “Hit Cmd+1 to open project window – on the left drawer your project should be selected – in the middle window you should see Project > your project name, underneath you should see Target > 2 target files (1 is your project name the other is projectname.tests). Choose “projectname” under targets. Click “add build phase” on the bottom right. Click “add run script” > paste in the script from the guide above.
Thanks!
Stewart – Try deleting your old cert and creating a new one. Also make sure that you have “Don’t code sign” selected in your project settings as you aren’t using those.
Yea this had me stumped for a little while too. Although I did it this way:
Create a new project and it’ll open on the project settings page. Across the top is Summary, Info, Build Settings, Build Phases and Build Rules. Go to Build Phases.
Now in the bottom corner you’ll see ‘Add Build Phase’, click that and select ‘Add Run Script’.
Hope this helps 🙂
Scott
Hi,
I m a newbe to Mac, stuck on step 5, when typing \vi script\ in terminal it open a text editor, I copy paste the next script and then I stuck what it mean typing \: x enter\ don’t know how to execute it.
Is there a better way to run the script, please help.
Vadim
I also get the …
“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”
… error message.
Recreated the “iPhone Developer” keychain multiple times, but didn’t help.
Any solutions?
I have successfully added the build phase code, but when I try to build and run I get the error \Command /bin/sh failed with exit code 1\
Any ideas what I causing this? I googled the error with no helpful results. :/
Vadim, just press Esc before you type 😡
Gerard Henninger, have you checked the clock on your iPhone? Does it match your computer’s time/date?
😡 = : x without the space :S
Ross; maybe check that the file /Developer/iphoneentitlements401/gen_entitlements.py is there and that it’s chmod is 777? Thats all I can think of myself?
Thanks so much!
I was watching videos, and roaming the internet when i stumbled upon your guide.
Very good instructions, I personally prefer using the command line, as the GUI can get clumsy, cluttered, and irritating.
It took me about 30 minutes to complete (I’m slow). Thanks for the great steps, now I can play my games on my iPod touch 4G (4.3.1 OS, XCode 3.2.5).
I have a problem in build phase.
It compiles and installs the program in my device but it crashes on debug in step 7 I copied/pasted the code. At first it gave the exit code 1 error, then when I checked on “Run script only when installing” it installed having this problem. Can somebody help me a little please.
Thanks in advance.
Unfortunately Xcode 4.1 (not sure about 4.0) does not have the “Use for development” button in the “Organizer Window” Any thoughts/suggestions would be greatly appreciated.
cheers
-C
I had the same problem but it was to do with my phone not xcode. I’d ‘Used for Development’ before and I think that stopped it from being picked up correctly…. Well at least after an iPhone restore it sorted itself out for me and the button showed up fine.
@Scott Walker, so if the button appears in the organizer window, then you wouldn’t mind posting a screen capture of the button in Xcode 4.x would you?
[…] […]
I certainly can. Excuse the iPod name, it’s my wife’s 🙂
http://i54.tinypic.com/2r2urcw.png
Oh incase you’re wondering, the only reason I used the iPod instead of my iPhone, is my iPhone is already used for development so the button won’t be there now.
PLEEEEEEASE Guys, help me out!!!
I have the same failure like @gerhard henninger (and HAD the same failure like Ross, but was easily solved by deleting my old university iphone developer certificate, which is expired!).
Yeah, but this time I’m ABSOLUTELY not figuring it out what the problem is….
Thats what Xcode does:
0. (Building prefix-blabla, and other blabla…..)
1. Running 1 of 1 custom shell scripts
2. Running ABCDEF on Iphone from ME
……no Warning no red popups all over the screen, just this tiny nasty message:
Please verify that your device’s clock is properly set, and that your signing certificate is not expired.
(0xE8008018).
I’ve synced just a hour bevor with iTunes so NO, my clock’s fine and I setup my signing certificate to 7300 days (should probably be enought!).
WHAT’S GOING ON?????!!!!!!! What could I have done wrong, what you guys have apperently done wright?!?!
THX, for every advise,
greez
yeah and I’m on Xcode 4.0.1, iPhone 4 and iOS 4.3.1 …….. PwnTool 4.3 and yup of course, Appsync 4.0+ (works like charme execpt here with Xcode!)
thx
Hi,
Is it correct to mark the flag “run script only when installing”?
If I don`t mark it, the error is:
iPhone Developer: no identity found
Command /bin/sh failed with exit code 1
If I mark it, the error is:
“Error launching remote program: failed to get the taks for process XXXX.
Maybe I`m missing the certification part as Ryan said… how can I get this certificates? In the organizer I don`t have anything in the Provisioning profile… maybe this says something to you.
Thanks,
Roberto
Just wanted to say that everything seems to work fine now.
I got the “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”” error, and this is how I “fixed” it :
– Updated to the latest XCode (4.0.2 as of this writing)
– Restored my iPhone to firmware 4.3.1
– Jailbraked it again
– Just installed AppSync 4.x+ (no other jailbroken apps)
– Created a Code-Sign-Certificate (Keychain Access)
– Followed the instructions above.
And now I can finally debug and run my apps on my iPhone!
I have to change this command:
cd /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk
to this:
cd /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk
Am I right?!
i think i hit the use for development button before I did this tut so its not there any more is there and way i can delete somthing to get it back?
cause I get this error [BEROR]Code Signing Identity ‘iPhone Developer’ does not match any valid, non-expired, code-signing certificate in your keychain.
xcode 4.1 thanks
also I dont appear to have the Certificate Assistant anywhere in the keychain utility in os x lion ??
Using XCode 4.0 and trying to get iPod 2G 4.2.1 running, but I can’t manage to create a “provisioning profile”, which seems to be required. The only option is “Add Device to Provisioning Portal” which brings up the login. Pressing Cancel and nothing happens.
Any ideas?
Just did this method with XCode 4.0.2 and iPhone 3gs JB`d with Greenpois0n running iOS 4.2.1 and it worked pretty well on my MacBook Pro i7 😀
Ty for this tutorial
Thank you very much! work for me like a charm!
btw… is it possible to compile it to ipa? (maybe somehow throw the device itself?)
Hey guys!
THIS IS THE BEST! It is the only tutorial i found that worked! Thank you so much for posting it.
You mentioned that the app would open, crash and then it would load fine. I am using tethered ios 4.2.7 jailbreak for verizon iphone 4 and that is happening to me. I haven’t installed any other apps in cydia other then openssh and appsync. Does anyone have a suggestion? And if all possible could someone shoot me a email if you reply? i prob will forget to check the site. Thanks again!
Dang forgot my email: [email protected]
Hi,
Thanks for the tutorial, I following all the steps but I got the following error when I try to execute on my iPhone.
Xcode cannot run using the selected device.
No provisioned iOS devices are available.
http://i54.tinypic.com/2a0gkjl.png
I connected my iPhone and I can see it on Organizer window. When I click Run button I got the error.
I already added the following script under Targets and Installed AppSync for OS 4.0+
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
I’m using XCode 4.0 and iPhone 3GS on OS 4.2.1
Any help is much appreciated.
puyo
I did this for my jb 4.3.1 iPad and Macbook Pro i7 with Xcode 4.0.2.
When running it on my iPadI keep getting..
Error Starting Executable ‘TestApp’
Error launching remote program: failed to get the task for process (some number here).
It looks like it deploys the app to my iPad, but Xcode cant run/debug it.
After it deploys, I can run it on my iPad independently though.
Thanks
I followed all of the steps but I keep running into this error when attempting to run on any IOS device..
“No provisioned iOS devices are available. Connect an iOS device or choose an iOS simulator as the destination.”
I’m running XCode 4 with the 4.3 sdk
Iphone 4, 4.2.6 firmware
Am i missing something?
Hi. Thanks for the post. I’ve done the process several times to always get to the same point: when i connect my ipod and before i can press the “use for development” i get this waring: “Unknown iOS detected. Xcode does not have debugging information for the version of iOS on the device named “PhiPod”. Xcode can collect debugging data from the device to enable development with this version of iOS. This process only needs to be done once per iOS version, and will take several minutes.” If i press collect (the other option is cancel) i get the message that says that xcode doesn’t recognize the SDK. My xcode is 4.01 and my ipod is running 4.3.1 (8G4) JB. Do i need to downgrade to 4.3? I would really like that someone could help me.. thks!
oh and the error when it tries to collect the image is: \xcode cannot find the software image to install this version\ :s
That just means you’re using a version of the iOS SDK earlier than the version of iOS currently installed on your system. For example, if you just updated to 4.3, but the last SDK you installed was 4.2, you’d get those sorts of messages. But be warned, I haven’t tried this method lately at all. I’ve seen in these comments people having success, but mixed.