IOS – Is it possible to compile and run an Xcode project on a jailbroken device without a paid developer certificate

iosiphonejailbreakxcode

Both for kicks and for budgetary reasons, I'd like to take a package that would normally require a developer account and build an app to run on a jailbroken iOS device.

I have a 5th gen iPod Touch, jailbroken using evasi0n, running iOS 6.1.

I am using Xcode 4.6 with OS X (10.8.2) Lion.

Best Answer

The following instructional steps to accomplish this purpose are taken from: http://iphonedevwiki.net/index.php/Xcode

My findings and actions are provided under each step.

1. Create a self-signed code-signing certificate with the name “iPhone Developer” on the “login” (default) keychain using Keychain Access.

  • I took screenshots as I followed the above instruction.
  • I left most fields blank or at their default value.

enter image description here

2. Open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Info.plist (4.2 or below: /Developer/Platforms/iPhoneOS.platform/Info.plist). You may need root permission.

  • I'm using Xcode 4.6, so I opened the former .plist file.

3. Replace all occurrences of XCiPhoneOSCodeSignContext by XCCodeSignContext. There are three of them (XCode Version 3.2.4+).

  • I made three modifications as the screenshots indicate.

enter image description here enter image description here enter image description here

4. Save the file and restart Xcode.

  • Saved the file.

5. Make sure you have ldid on your Mac. Place a copy somewhere e.g. in /usr/local/bin.

6. Create the a Python script ldid3.py right next to the ldid program. Make it executable. Fill it with:

#!/usr/bin/env python

from sys import argv
from subprocess import check_call
from os.path import basename, dirname, splitext, join
from tempfile import NamedTemporaryFile

app = argv[-1]
ldid_path = join(dirname(__file__), 'ldid')
obj_path = join(app, splitext(basename(app))[0])

if '-gta' not in argv:
    check_call([ldid_path, '-S', obj_path])
else:
    with NamedTemporaryFile('w+b', 0) as f:
        f.write("""
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>get-task-allow</key>
    <true/>
  </dict>
</plist>
        """)
        check_call([ldid_path, '-S' + f.name, obj_path])
  • I created a new plain text file and copy-pasted the above code into it.
  • I saved this file as ldid3.py and stored it in the /usr/local/bin directory.
  • In terminal, ran chmod 777 /usr/local/bin/ldid3.py.

7. Open iPhoneCodeSign.xcspec. This file can be found in [For Xcode 4.6: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/iPhoneCodeSign.xcspec]:

8. Change the entry in the file from calling codesign to ldid3.py.

  • As per instruction official instruction, converted the spec file to plain text by typing in console: sudo plutil -convert xml1 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/iPhoneCodeSign.xcspec
  • I opened the file with TextEdit.
  • Replaced <key>CommandLine</key><string>/usr/bin/codesign</string> with <key>CommandLine</key><string>/usr/local/bin/ldid3.py</string>.

9. Save the file and restart Xcode.

  • I saved the file and quit TextEdit.

10. Create a file /var/mobile/tdmtanf on the device, to enable Apple's "TDMTANF bypass" in installd (warning: doing so will also put you in a sandboxed GameCenter).

  • I create an empty text file in Windows, named it tdmtanf, SSH'd into my iPod, uploaded it to /var/mobile/, and reboot my iPod.

Now that all that is over with...

I open my existing Xcode project and hit Run. It works in the iOS Simulator without any problems.

enter image description here

I make sure that Code Signing is set to use the certificate set up in step 1.

enter image description here

I build the app (Project > Build). A success message follows.

I grab my app folder TicTacToe.app from /Libary/Developer/Xcode/DerivedData/TicTacToe-cjgzmoxtflyegtfypsbxbuiuwxns/Build/Products/Debug-iphoneos/ and transfer it to my Windows machine to install onto my iPod.

In an attempt to install the app to my iPod, I drag TicTacToe.app onto the applications section of iPhone Configuration Utility, but I received this error message saying that my app "is not a valid mobile application."

I have also tried manually installing the app using iFunbox and the AppCake app found in Cydia. Both fail.

enter image description here enter image description here

As a point of interest, because as I've Googled around, I've noticed many people mention the importance of this: I do have AppSync installed. (Sorry for the huge screenshot. If I should take it down, please let me know!)

enter image description here

Conclusion

So despite following the instructions closely, several times, my app is not recognized by iPhone Configuration Utility as a valid app. I cannot install the app manually using programs like iFunbox, or Cydia apps like AppCake.

I suspect the app is indeed invalid, but having followed the instructions carefully, I'm not sure why.

Can anyone tell me why my app is not valid, and what I can do to fix this, besides coughing up money that is?