So I built an iPhone application in xCode without $99

I’m developing for the iPhone, and I even got a Macbook, but I don’t really want to start my $99/year until I’m ready to publish something to the AppStore. So, how do you develop with xCode for the iPhone, without an Apple Developer certificate?

  1. Download and install xCode and the SDK from the iPhone developer center. Run the installer.
  2. Create a self-signed certificate on your mac.

    Start Keychain Access: Open Finder, Utilities (shift-command-U), Keychain Access. Then Keychain Access, Certificate Assistant, Create a Certificate. Enter the name “iPhone Developer”, Self Signed Root, and check Let me override defaults. Continue, and Continue again – that you’re creating a self-signed certificate.

    Serial number 1 should be fine, make the validity period longer so you don’t have to mess with this again (3650 days sounds good…), and choose Certificate Type: Code Signing. Continue, enter an email address, I put “iPhone Developer” in the certificate information here, too, and then just hit Continue until it creates the certificate.

  3. Download a project of your choice from the Apple iPhone developer pages (I grabbed WhichWayIsUp). Open the .dmg and copy the files (or the .zip and extract the files) into a directory you can edit (I put it under $HOME/Documents).
  4. Open the xcode project file (or the project file from xcode).
  5. Turn off built-in code signing: open Project settings (Project | Project settings). Choose the Build tab. In the Code Signing section, for Any iPhone OS Device, erase the name “iPhone Developer” and leave it blank.
  6. The jailbroken iPhone still needs the code to be marked as “signed” (or the application gets killed on startup), so add a custom build step to sign the executable (you’ll need to do this for each project – and I haven’t found where to update it after adding it…):

    Download gen_entitlements.py and place it in $HOME/bin. Make it executable (chmod 755 $HOME/bin/gen_entitlements.py).

    Add the build step to execute gen_entitlements.py:

    Project | New Build Phase | New Run Script Build Phase

    Add the following script code (note that you need to update $HOME/bin depending on where you put gen_entitlements.py. You may also want to update the my.company text):

    export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
    if [ "${PLATFORM_NAME}" == "iphoneos" ]; then
    	$HOME/bin/gen_entitlements.py "my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent";
    	codesign -f -s "iPhone developer" --resource-rules "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/ResourceRules.plist" \
    		 --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent"  "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"
    fi
    
  7. Choose the iPhone as the Active SDK: Project | Set Active SDK | Device – iPhone OS 2.1
  8. Build the project (command-B). If prompted, allow the use of the iPhone Developer key to sign the code. (I choose Always allow).
  9. Copy the built file to the iphone (update text as needed): scp -r ~/Documents/WhichWayIsUp/build/Debug-iphoneos/WhichWayIsUp.app root@miphone:/Applications
  10. Refresh the Springboard cache. You can do this in several different ways. Pick one:
    • Install or update an application via Cydia or AppStore
    • Use the Cydia application “Respring”
    • In the Cydia package “BossPrefs” touch the Power icon, then “Fast Respring”

  11. Your application should show up in the Springboard. Run it, and enjoy. (Or be disappointed that the box in WhichWayIsUp doesn’t rotate smoothly, but only switches to vertical/horizontal. *sigh*)

Much of the detail of this process and the gen_entitlements.py script came from Sylvain Munaut – Thanks! Note that I did not need to install the binary patches he lists at the end of his process.

11 Comments »

  1. Graham Said,

    February 27, 2009 @ 6:48 am

    Warning: This doesn’t work if you update to iPhone OS and SDK 2.2.1!

  2. kb Said,

    March 3, 2009 @ 9:03 am

    Actually, it does. I need to make an updated posting. Basically, I disabled the code signing and just use ldid -S to make the application executable.

    I’ve been doing it daily, and almost have my app ready to ship in the AppStore – time for me to pay my $99 and get it available.

    kb

  3. Mike Said,

    May 14, 2009 @ 9:35 am

    Awesome! Just got this working! Thanks so much! :D

  4. Phil Said,

    May 27, 2009 @ 10:46 am

    Hi, Could you please expand on what steps you have to do with the 2.2.1 SDK?
    I am new to this and like you would like to try building and running apps on my iPhone before signing up to be a developer.
    Thanks.

  5. Mikey Said,

    June 17, 2009 @ 9:35 am

    ive almost got this working, getting hung up on something to do with resourcerules.plist, im able to copy the app to my iphone(unsigned though) the eror im getting when building it is:

    ‘Command /bin/sh failed with exit code 1′
    ‘/Users/Mikey/Downloads/WhichWayIsUp/build/Debug-iphoneos/WhichWayIsUp.app/ResourceRules.plist: cannot read resources’

    and im seeing it in the script above and the file in nonexistent in the app so any help would be greatly appreciated, thanks!

  6. falk Said,

    July 22, 2009 @ 2:02 pm

    Got the same mistake as mikey. Seriously need help with this

  7. rahul bhargava Said,

    August 5, 2009 @ 11:52 pm

    Hello Sir,
    I made a demo iphone application in xcode and working fine and i wish to give some kind of setup or exe file to give my client so that he can see the demo . i am not very much clear that in above tutorial what we are doing is it that what i need or something different .
    I am not clear with step 3,4,5,6 please help me or suggest me how can i give demo to my client or how can i make setup of my iphone app so that it can be easily install in any iphone device.
    I will be very thank full of you.

  8. mehroz Said,

    November 18, 2009 @ 12:21 am

    thanks for sharing such a good tutorial … it really helped… well m having a lil problem i made the whole project according to the steps that are given in this tutorial yet m left with only one error “Command /bin/sh failed with exit code 1″ …. looking forward for help :)

    Mehroz

  9. moid iqbal Said,

    December 21, 2009 @ 2:48 am

    we need to give demo to our client in US. is there anyway where i can show demo to my client on there iphone?
    Code is with me.

  10. kb Said,

    December 22, 2009 @ 9:56 am

    mehroz, if you could give more detail about what you were doing when you encountered that error, I may be able to help.

    kb

  11. Ingo Said,

    January 30, 2010 @ 10:20 am

    Hi,

    is this possible without jailbreaking the iPhone?

    thanks for your work!
    ingo

Leave a Comment