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.
Iulian i have the same problem, does compile but not run in the iPhone
thank you for the great article, thank you Shahin, I can revolve my problem !!!, thank you very much.
In my last issue the solution is add armv6 in proyect-> build setting->architectures
For me only openGL game project wont work on the iphone(iphone 4 ios 4.3.3) , the rest of the project work on bouth (ont the simulator and the iphone)! Any ideea?
tnx,
Iulian
After hours and hours of browsing and tweaking I finally figured this out :D! I can confirm that it works on iOS 5.1, but for some reason I can only get it to build in Xcode 3.2.6. In Xcode 4.3.2. I get “CodeSign error: code signing is required for product type “Application” in SDK “iOS 5.1”
Would really love some assistance if you guys could.
Hey Willy, check out my previous comment:
http://www.alexwhittemore.com/developing-jailbroken-iphone-ios-401/?replytocom=8046#comment-8026
This is needed for new xcode.app 4.3.1
Thanks you very much Shahin, that saved me a lot of frustration!
@Dave, paying $99 for device app deploying, testing or debugging IS NEVER a WASTE of MONEY…and never will… 🙂 poor self-teach kid like me try what Alex and others Shared to is solely to SAVE MONEY,.because personally i can’t afford paying in dollars.
Thanks Alex! And all who helped here..
It ‘WORKS’ for me.. MY system: Mac OSX Lion 10.7.3, Xcode 4.2.1 iOS SDK 5.0.1, and JB’ed iPad2 iOS 5.0.1..
Just follow Meg’s advice:
to use this path:
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneOS Build System Support.xcplugin/Contents/MacOS/
…if you have problems in VIM editing stuff:
(A) http://blog.interlinked.org/tutorials/vim_tutorial.html
or
(B) http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html
…or…like me, if you’re not much versed in doing so, you can use PlistEdit Pro.. any PlistEditor,. just learn how to duplicate the original copy, edit outside the directory, then put it back onto the original directory to replace the edited plist file.
..make sure to type and execute the codes one-at-a-time and with extreme caution on any typos.. 🙂
Good luck!
🙂 Happy coding!
[…] http://www.alexwhittemore.com/developing-jailbroken-iphone-ios-401/ […]
Thanks! Just tried this on a hackintosh running xcode 4.3.2 (OSX Lion 10.7.4) and it works great (including debugging on the device). Just wanted to point out a few modifications to the instructions I had to make to get it to work:
1. As mentioned by Shahin, locations of plist files is now
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Info.plist
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/SDKSettings.plist
2. 1st line of script should read:
cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS/
3. You now have to run script using sudo:
sudo ./script
4. Change first line of build phase script
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
Hope this helps someone
Forgot to mention, to be able to and run on a device running older firmware (e.g. 4.2), I had to change the “iOS Deployment target” version in the project build settings
yes i do encountered problems “pakee” mentioned above.
and it’s all solved now with the help of his tips.
Thank you ~!
Worked great on Xcode4.2 on Lion. Thank you!
Lion 10.7.4; XCode 4.3.2; iPad3 iOS 5.1.1; JB Absinth 2.0.1
I do not get it to work.
Adapted the modifications suggested by pakee
Step 5 gave me:
./script
55+1 records in
55+1 records out
In Xcode:
iOS Target: 5.1
Code Signing: Don’t Codesign
I can create an IPA project file and upload it via iTunes to the iPad.
I can start the app on iPad, however, the app closes instantly without crash report.
Help appreciated
I did most of it, but am having trouble with step 6, where it says “open Project>Edit Project Settings (from the menu). Click on the “Build” tab.” I can’t find Project anywhere on the menu. I am using XCode 4.
Thanks for the help.
hi i am having the same problem as Vdue everything is fine the app starts and it closes instantly. Please help
so i found the “solution” or idk more of a work around. put your phone in safe mode. then you will be ok….. if anyone knows any other way let me know!!
worked on 10.6.8 on vm virtualbox on windows 7. Thank you. It allowed me to write ios applications without buying a mac!
Is there a similar guide for Xcode 4.3.1 for iOS 5.1 ?
The techniques outlined in Alex’s guide with the folder location updates noted in the comments work with Xcode 4.4 iOS 5.1.1r1 but now adding the run script build phase to add self signed entitlements to a project is REQUIRED (no longer an option only needed for debugging). Apps will install but will not be allowed to run on a newer iOS (i.e. starting with 5.1.1) without signed entitlements even with AppSync installed.
Thank you Alex!
Folks,
Just FYI – I’ve put an updated version of this guide, tested for iPhone 4S 5.1.1 with Xcode 4.4.1 on Mountain Lion here:
http://i.vishalagarwal.com/post/30102590371/developing-on-jailbroken-iphone-4s-5-1-1-with-xcode
Thanks Alex for your blog post.
I am getting an error when i try and build my project:
/bin/sh: /Users/xxxxxxxxx/Library/Developer/Xcode/DerivedData/HelloWorld-ssmarcbfferolyggwwsaprblnfdc/Build/Intermediates/HelloWorld.build/Debug-iphoneos/HelloWorld.build/Script-FB44235035EBB4130266EB3D.sh: (null): bad interpreter: No such file or directory
Although the path is correct and the files names of the .sh is correct.
ok now i am getting :
iPhone Developer: this identity cannot be used for signing code
Command /bin/sh failed with exit code 1
although i do have it in my keychain (login)
nevermind….used another certificate 🙂 all good, thanks
[…] refer to: http://www.alexwhittemore.com/?p=398 […]
Hey guys, when I try to run my project I have this error :
Dest must be .xml (for ldid) or .xcent (for codesign)
“iPhone: no identity found
Command /bin/sh failed with exit code 1
This identity ‘Iphone’ comes from the script add in Xcode to run when building a project : codesign -f -s “iPhone Developer” —entitlements “${BUILT_PRODUCTS_DIR}/ ….. etc….
Thanks in advance for your help,
Arthur.
@Arthur
“iPhone: no identity found
probably means that you don’t have any iPhone or iTouch connected to use for Xcode.
Hi,
I found the solution, its due to error in tutorial. Check comment on this article : http://i.vishalagarwal.com/post/30102590371/developing-on-jailbroken-iphone-4s-5-1-1-with-xcode
Arthur.
[…] gerekli adımları takip ederek uygulamayı telefonunuzda da çalıştırıp deneyebliirsiniz: Developing for a Jailbroken iPhone A to Z (iOS 4.0.1) alexwhittemore.com burada anlatılan 4.0.1 için fakat 4.2.1 için de aynı adımları 4.0.1 yazan yerlere 4.2.1 […]
[…] gerekli adımları takip ederek uygulamayı telefonunuzda da çalıştırıp deneyebliirsiniz: Developing for a Jailbroken iPhone A to Z (iOS 4.0.1) alexwhittemore.com burada anlatılan 4.0.1 için fakat 4.2.1 için de aynı adımları 4.0.1 yazan yerlere 4.2.1 […]
AppSync is not available anymore… any alternative?
A guy give me a better alternative : jailcoder. Easier et faster but I have not try it personally.
Ahah… I’m the JailCoder creator 🙂
JailCoder is not an alternative, it just use the same method explained in this article, using a user-friendly and automatic approach (just a few clicks and no terminal skills required)
So… JailCoder needs AppSync too
Do you have try to contact the creator of Appsync to have some news ?
Hackulo’s team closed the project, there’s not much to do
http://hackulo.us/
AppSync from insanelyi repo doesn’t work?
Will this be updated for IOS 6 ? or is it the same way ?
As it stands, AppSync is no longer distributed, so this method won’t work anymore (and some other means of breaking signature checking would be needed). I’m pretty sure you can just use ldid before deploying to device as you would if you were signing for the cydia app store, but I don’t know enough about it. I may come up with a new guide in the future, but I’m not sure if I’ll be able to find the time/necessity.
but the appsync is available as a deb to be installed if someone doesnt have it. Wouldnt that work ?
Well, certainly it is, but I’d be shocked if the old .deb works on iOS 6+. Apparently the upgrade path for jailbreak apps was relatively rocky, I’d be totally surprised if an out-of-date version of such a low level modification still worked. And for that matter, it’s not getting updated going forward.
AppSync 2.2 does the job on 6.1 just fine. Ie. from i*****repo.com. Besides, with Xcode 4.6 the “5. real bad boy binary thing” isn’t relevant even.
yessss sinful released a new appsync 🙂 for IOS 4/5/6
It’s worth noting that for a fresh Xcode 4.6.1 install, the binary patching step has changed, the second line of the script should read:
cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneOS\ Build\ System
The PrivatePlugIns part changed.
It is appropriate time to make some plans for the future and it’s time to be happy. I have read this post and if I could I desire to suggest you few interesting things or suggestions. Perhaps you can write next articles referring to this article. I want to read more things about it!
Here is my blog post :: how to make a Android App
Tested with Xcode 5, did everything except the “5. bad boy binary step”, and it works 🙂 Using an iPhone 4 on iOS 6.1.2 still.
Tested with Xcode 5.1.1 on OSX 10.9.2, iPhone 5 with iOS 7.0.6, and it worked.
I also skipped “5. bad boy binary step” and I had to change all the /Developer paths to /Applications/Xcode.app/Contents/Developer in the scripts.
I also note that there were 3 mentions of “XCiPhoneOSCodeSignContext” instead of 2; I changed them all.
[…] used a mix of two howtos: Jason’s and alex’s. With the second we have the advantage of being able to debug. I’ll mostly just copy both […]
[…] http://www.alexwhittemore.com/developing-jailbroken-iphone-ios-401/ […]