Monday, September 21, 2009

Deploying your app on your iPhone or iPod Touch...

I was trying to deploy one app that I created to my iPhone for testing and debugging… I did not want to buy apple account before making sure that my app works fine on my iPhone…. I googled around for few days and found many articles for doing this… after trying all those finally I managed to get my app deployed to my iPhone. I have summarized the steps that I performed to get my app deployed onto my iPhone and iPod touch 3.0… I have referred various sources and compiled those into one article for ease of use for others who are trying something similar to this.. Once you verify that your app works fine on device, then proceed to register yourselves on apple to get your app published on the appstore…


Scary note: Please perform all these steps at your own risk. You will be responsible if these steps damage your iPhone/iPod/MAC.. Make sure you backup all data on your iPhone/iPod/MAC before proceeding…

1. Jailbreak your iPhone or iPod and upgrade to OS 3.0. (there are many articles on jailbreaking your device.. you may google for it)

2. Install OpenSSH from Cydia on your iPhone/iPod. Cydia is installed once you jailbreak you iPhone/iPod.

3. Install the Installd patch to your device from Cydia.

4. Create a self signed certificate on your mac.
  • Open Keychain Access on your Mac
  • In the menu, go to "Keychain Access -> Certificate Assistant -> Create a Certification"
  • Name it "iPhone Developer" and choose "self-signed root" and check "let me override defaults" and proceed.
  • Now change Certificate Type to "Code Signing". Click continue to accept defaults for rest of the screens.
  • Once it's created, navigate to Keychain Access' Certificates list and right click -> Get Info, under Trust change "When Using This Cert" to "Always Trust".
5. Edit the following files on your MAC.

a) /Developer/Platforms/iPhoneOS.platform/Info.plist
Look for the key “OverrideProperties” in this file and add the following entries to it,

<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>NO</string>

<key>PROVISIONING_PROFILE_REQUIRED</key>
 <string>NO</string>

If the lines already present, make sure the string value is set to “NO”

b) /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/SDKSettings.plist
           Look for the keys,
                       <key>CODE_SIGNING_REQUIRED</key>
                       <string>NO</string>
                 and
                        <key>ENTITLEMENTS_REQUIRED</key>
                        <string>NO</string>

Make sure that the string values are set to “NO”. If not found add these entries to the <dict> under DefaultProperties key.

6. Now open Xcode on your MAC and open the project file of the app that you want to deploy to the device..
  • Edit projecting from "Project-> Edit Project Settings”.
  • In “Build->Code Signing Identity”, change “Any iPhone Device" to "Don't Code Sign".
  • Compile the program with the Active SDK set for "iPhone Device" instead of "Simulator".
  • Under "Executables", drag the newly compiled app to somewhere that is easy to get to from the terminal.
  • In a terminal, run 'codesign -fs "iPhone Developer" /path/appname.app/appname'
  • Transfer “appname.app” to your device (/Applications) using ssh. (Use winscp or any of your favorite ssh client)
                             Default ssh username: root and pwd: alpine

              Make sure that the appname.app permission is set to 0775 (including all its subfolders and files)

If you have your iPhone connected to your MAC/Xcode using the developer profile, you can directly install the app onto your phone from xcode.. need not use ssh…


Have a nice time.. Enjoy ;)