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.
thks for the fast response Alex. Im downloading 4.3 SDK right now and gonna format my ipod, then try this method to get it working..
One other thing: with the old xcode (3.x.x) e just built the apps and then with SSH copied them to my ipod /Applications and worked. now it seems i cant do that, can i?
If anything, that might be ALL you can do. It’s build-and-go debugging people seem to be having some trouble with.
hey Alex, now i have even bigger problems :s i cant downgrade to 4.3. i always get errors when following this guide http://www.redmondpie.com/downgrade-ios-4.3.3-to-4.3.2-4.3.1-4.3-4.2.1-iphone-4-3gs-ipad-2-ipad-ipod-touch-4g-3g-how-to-tutorial-guide/ i do everything like they say, except for this: “NOTE: This guide will only work if you have SHSH blobs saved for the respective firmware you downgrading to.” and i dont know how to do this. i downloaded via cydia iSHSHit and tried to get the 4.3 and get the error: ” The request firmware is no longer available for signing.” any thoughts?
Unfortunately, you’re out of luck. With newer devices, apple uses what’s called an SHSH hash check. Every time you try to install an OS, the actual OS image has to be signed with a device-unique hash that apple’s servers generate special for you. tinyumbrella and cydia/ishshit handle requesting signatures for you, such that you can downgrade. But if you haven’t captured the signatures for your specific device before Apple stops signing that OS version, you’re out of luck: you’ll never be able to install that version on that device. So in your case, you just can’t downgrade.
yes, thats the concluision i got after googling a little bout it.. :s but thks for the explanation. anyway i dont understand how no one here had the same problem i’m having 😐 the problem i have is when connecting to the Organizer it doesn’t let me choose “use for development” cuz it needs the SDK, and when trying to collect from the ipod it gives me an error… ARGHHH!!!
I think the only thing i can do right now is to set my ipod with the 4.3.3 (latest) iOS and connected (unjailbroken) to the Organizer.. After this i just have to wait for the jailbreak and pray it works. what do u think Alex?
Hey Alex! Just searched on the web and found this: “You can get the xcode4 build behaviour by changing Build Location under Locations in Preferences from the default “Place build products in derived data location” to “Place build products in locations specified by targets”.” I tried it and got the HelloWorld.app in my project folder! 😮 I can’t try to send it to my ipod via SSH, cuz here I have proxy and can’t connect through cyberduck, but as soon as i get home, im gonna try, and if that works, than for ppl that want to code, try in the simulator and then try on the ipod, this solution is pretty easy and simple! 😉 ill leave feedback later.
Hi Alex, is there any workaround for Titanium Appcelerator ? I would like to use this “Bridge-ing” app to write one source code for Android & iPhone (or at last some portion of it) but as you can see by your self it is impossible to package an *.ipa file because of the “developer license” is mandatory. I’ve tried numerous ways to get it working – but each failed. It even creates some kind of XCode project but that is not using their special “JS-2-ObjectiveC” compiler. Can you please offer me some help ?
Hum i uploaded via USB with DiskAid. but when i select the app on ipod, the screen goes black and then back to springboard again… in DiskAid I can check the files in the .app (and comparing to other apps, there are some files and folders missing such as the folder _CodeSignature …) grrr :s
i set 4.3.3 unJB and tried the organizer. it now recognizes the SDK, but no button of “use for development” whatsoever 🙁
Hi.. i did everything on the guide, got no errors during the process.
After doing evrything i did Build > Run.. it runs fine on iOS Simulator. what i dont understand is how to get the app on iphone? Should i just copy the \trial.app\ from \/trial/build/Debug-iphonesimulator\ to /Applications on my iPhone or is there some other way.
Sorry if its a stupid Q, i’m a newbie
Fantastic, big thanks for this! Worked flawless. When doing “Build and Debug” first time around I got an error about application already installed – that was due to me already uploading it manually for debugging with gdb. So go to /Applications and delete it, and all good!
Hi, I tested this on xcode 4.0.1 and iPod Touch 4g 4.3.3. My snow leopard runs on vmware. No problems here. I was able to deploy and debug my app. Thanks much Alex!
I did it! 😀 thanks to Gerard Henninger (April 15th, 2011 – 22:30) I was able to surpass the ‘clock thing’ problem and I just tried my app in my ipod. my system is xcode 4.0.1 and I have 4.3.3 JB on my iPod 4G. (notice that i had to have it unJB to add it to the organizer). Well Thank you so much for everything Gerard and obviously this whole guide 🙂
duuuuuuuuude , you are AWESOME !!!!
Very nice, you are great, it works for me perfectly
Alex, had this working ages ago, thankyou so much.
I recently upgraded to latest 4.0.1 xc + 4.3.3 JB on 3GS.. The *same* error that I had previously regarding the “symbols” for debugging occurred, last time it was Backgrounder.
I did disable multitasking (http://jaxov.com/2011/05/disable-native-multitasking-on-iphone-ipod-touch-ipad-running-ios-4-3-3/) and when i tried to install Backgrounder it failed.. but i didnt persist.
Any ideas what I could be doing wrong?
Thanks
Sam
Alex,
Here is the output, maybe its all working fine, apologies in advance, am just getting back into this after a long break.
Thanks
Sam
GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:56:02 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “–host=x86_64-apple-darwin –target=arm-apple-darwin”.tty /dev/ttys000
target remote-mobile /tmp/.XcodeGDBRemote-661-35
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to process 11779 thread 0x0]
[Switching to process 11779 thread 0x0]
Re-enabling shared library breakpoint 1
warning: Unable to read symbols for /Library/MobileSubstrate/MobileSubstrate.dylib (file not found).
warning: Unable to read symbols for /Library/Frameworks/CydiaSubstrate.framework/Libraries/SubstrateLoader.dylib (file not found).
2011-05-28 23:39:57.045 Slider4[597:607] MS:Notice: Installing: sammys.Slider4 [Slider4] (550.58)
2011-05-28 23:39:57.090 Slider4[597:607] MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/Activator.dylib
warning: Unable to read symbols for /Library/MobileSubstrate/DynamicLibraries/Activator.dylib (file not found).
2011-05-28 23:39:57.622 Slider4[597:607] MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/IntelliStatusIconsView.dylib
warning: Unable to read symbols for /Library/MobileSubstrate/DynamicLibraries/IntelliStatusIconsView.dylib (file not found).
2011-05-28 23:39:58.185 Slider4[597:607] Initializing IntelliStatusBarIcons v0.93
2011-05-28 23:39:58.195 Slider4[597:607] Initialized listener for icon updates
2011-05-28 23:39:58.244 Slider4[597:607] MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/WinterBoard.dylib
warning: Unable to read symbols for /Library/MobileSubstrate/DynamicLibraries/WinterBoard.dylib (file not found).
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/usr/lib/libsubstrate.dylib (file not found).
2011-05-28 23:40:00.422 Slider4[597:607] WB:Notice: WinterBoard
MS:Warning: message not found [UIImage defaultDesktopImage]
2011-05-28 23:40:00.502 Slider4[597:607] MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib
warning: Unable to read symbols for /Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib (file not found).
2011-05-28 23:40:01.256 Slider4[597:607] Could not find mapped image Silver_LINotif.png
Program ended with exit code: 0
Tks a Lot it works for me – congratulations!!!
I was able to run it on iPhone 4 by enabling breakpoints and then starting the debug. It gives an error sometimes but keep trying as it does work too.
Can I translate this article to porguese and put on my blog? With link back 🙂
Sam – it looks like you have a broken installation of something else, maybe notified? Something that puts notifications in the title bar.
Michel – of course, thanks for asking!
This works for debug, but when I try to build a release version I get the code signing error. anyone have any thoughts on that?
Hey Alex,
I’ve been able to do steps 3 and 4 using terminal but when I do step 5 in Terminal nothing happens. Am I supposed to be using another program or how do I do this is Terminal?
Sorry, I had this working on an older Xcode and I’ve forgotten how to do it :/
Thanks!
[…] refer to: http://www.alexwhittemore.com/?p=398 […]
Could not create application container!
COuld not create application container
COuld not create application container, xcode error
Hi Alex !,
Please can you help me ? I’ve got a little problem: after paste this code into the terminal :
#!/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
I’m trying to type “:x” and then enter but my terminal returns this error:
…chmod a+x iPhoneOS\ Build\ System\ Support:x
chmod: iPhoneOS Build System Support:x: No such file or directory
What i’m doing wrong ?
Thank you for your time !
@ FoxDev, try pushing ESC then doing that combination!
the problem is that you never entered VI, you’re just pasting that all directly into a terminal window (which won’t do anything). Follow the step to launch vi right before that.
Hey Alex i get could not create application error when i build and debug and stuff. Any ideas? -SlyCLick
Oops i mean application container error
Succeed to deploy to Iphone4. Thanks.
I would like to ask, before I want to submit the app to Apple, do I need to do anything to the Xcode or change back the project setting ?
[…] y arriver, j’ai suivi l’excellente procédure décrite sur cette page : http://www.alexwhittemore.com/?p=398. Comme cette procédure est en anglais et qu’elle utilise des outils difficiles […]
Hi,
Will it work on xcode 4?
Thanks!
Just FYI – seem to have got this working with XCode 4.0.2 and an old iPhone 3 with iOS 4.2.1.
Step 6 could do with updating to suit the new layout of XCode.
Step 8 seemed to be a bit convoluted for me, perhaps because I already had a provisioning doohickey and had to try to make XCode forget it before I could tell it to not have one?
Also had to change the Deployment target to ios 4.2 before the system would even accept my iPhone as being available.
Now I just need to find out how to get to run code in processor privileged mode…
Hi,
I’m working on Xcode 4 & IOS SDK 4.3 for creating iphone application. Application has been successfuly builded and shown in Iphone simulator. I would like to test it on my personel jailbroken iphone ios 4.01 and don’t want to pay 99$ just for testing my application. I’m new in iphone development and would like to know wheather there is any way to do it.
Note, that i have passed all steps provided in this site, the build succeeds for Ios 4.3 device. But it doesn’t generated any .app or .ipa file. I could only get the .xarchive file.
Please, help me to put the application on my iphone.
Thanks!
Amazing! it just works! Congratulations, great tutorial! Asking for permission to translate it.
Amazing! it just works! Congratulations, great tutorial!
Hi Milton. I would like to know how you works your application on real iPhone device? I have tried all the steps described and all them succeeds but with no result, i could not see it on my iPhone. I would like to know what is your version of Xcode and ios sdk and also the iphone ios version?
thanks in advance
Perfect!! Thank u alot, i worked fine :
Iphone 4
IOS 4.3.2
XCode 3.2.6
Thank thank thank thankssssssssssss
I am able to build and run in the simulator successfully. But when I choose “Device” I get the error “Code Signing Identity ‘iPhone Developer’ does not match any valid, non-expired, code-signing certificate in your keychain” in the release mode and “iPhone Developer: this identity cannot be used for signing code” in the debug mode. Please help.
I checked my keychain and could see iPhone Developer certificate under system. Initially I had it under Login it failed so tried moving the certificate to System even then it fails.
Hi Alex, Its working now! I created a new project and chose debug mode, the app got installed successfully in my iPhone. Thanks for such a great guide.
Dear Alex,
Your tutorial is great. But I have a problem.
Now I want to revert Xcode to original state, with no “don’t code sign”, but I don’t know the way.
Please help me.
Dear Alex,
after experimenting a lot and carefully doing all the steps of your tutorial, finally I’m able to use the debugger.
Using XCode 4.0.2 with IOS 4.3.3.
Thanks a lot.
Hi kp,
I have the same message, what was the problem?
HiddenDev,
any changes to the above steps ?
Great tutorial, thanks a lot!
Thanks Alex! This is a fantastic tutorial which I’ve used on xcode 3 for some time. But xcode 4 had me stumped. Kept getting the “No provisioned iphone OS device” and after weeks of Googling found the answer in another article from you: http://www.alexwhittemore.com/?p=135#more-135 that mentions this could actually be a mismatch in iOS levels. I went into the Target screen for my project, found Summary>Deployment Target, changed the version to match my phone, and everything worked! (see also tim Rowledge’s comment from 6/20/11)
Gabriel
This is a great tutorial, thanks! I just have one question. How do I save the .plist and exit the editor?