Tuesday, December 29, 2009

Sign and deploy app to iPhone device

A. Create a Certificate Request on disk
- Start application "Keychain Access", use "Certificate Assistant" to request a certificate from Certificate Authority.
Be sure ...
a) The common name match your registered name in iPhone Developer Center
b) Select the checkbox "Let me specify key pair information". If you missed this checkbox, the certificate signed contains only the public key. Use keysize=2048, algorith=RSA.


B. Create iPhone provision file
The most easy way is to login iPhone Developer Program Portal with "agent" privilege. On the Portal home page, launch the "Development Provisioning Assistant", select the saved certificate request from step A. Follow the steps from the Assistant, you also need to have
- Create App ID (e.g. com.mycompany.*)
- Create Device (need to obtain the device ID through Xcode or iTune)
The Assistant will finished with a signed certificate *.cer and provision file profile_name.mobileprovision.

C. Add the certificate to keystore by double clicking the *.cer file.

D. Start XCode, open the "Organizer" window and drag and drop the profile_name.mobileprovision to the "Organizer" window.

E. Open project setting in XCode, check "Code Signing" setting of ...
Code Signing Identity=iPhone Developer :
.. Any iPhone OS Device=iPhone Developer :

F. Open your project's info.plist file, ensure the Bundle identifier has the App ID as prefix.
e.g. com.mycompany.${PRODUCT_NAME:rfc1034identifier)

G. Set the project's Active SDK to iPhone (debug or release), build and deploy by clicking "Build->Build and Go(run)"

Saturday, December 26, 2009

Remove unwanted app which doesn't show delete icon

1. SSH to iPhone with root account, root's password is alpine
e.g. ssh -l root

2. cd to /Applications@ (/Applications@ is a symbolic link to /var/stash/Applications)
delete the the unwanted application directory (says, HelloWorld.app)
e.g. rm -r -f HelloWorld.app

3. The icon on the home screen exists until iPhone restart.

4. Power off and restart iPhone, the unwanted application is gone.

Thursday, March 26, 2009

Good iphone programming book

Received the book ...
Beginning iPhone Development Exploring the iPhone SDK by Dave Mark, Jeff LaMarche

A very easy to read book, follow the first two chapters and completed the first two examples with ease.

The book example code is downloadable from
http://www.apress.com/book/view/9781430216261

Learned a trick from the book.
How to remove deployed app in iPhone Simulator?
Delete the directory ~/Library/iPhone Simulator.

Thursday, March 12, 2009

Deploy program to iPhone

I use iPhone SDK with 2.2.1 support. The SDK doesn't do the code signing check if you select the runtime of 2.1. A 2.2.1 iPhone runs 2.1 program as well. However, if you select 2.2.1 runtime for your program, you get code signer error on build.

You can sign up Apple's developer program and pay the $99 for a developer certificate, code sign your Hello World and deploy to the iPhone as per Apple instruction. I decided to defer this approach until I feel serious enough.

Instead, I took the following steps for a self signed identity to deploy my first iPhone program to the device.

1. Create a self signed identity "iPhone Developer" base on the following Apple note.
http://developer.apple.com/documentation/Security/Conceptual/CodeSigningGuide/Procedures/chapter_3_section_2.html

2. Edit /Developer/Platforms/iPhoneOS.platform/Info.plist with the
following:

<key>OverrideProperties</key>
<dict>
<key>CODE_SIGN_CONTEXT_CLASS</key>
<string>XCiPhoneOSCodeSignContext</string>
<key>DEBUG_INFORMATION_FORMAT</key>
<string>dwarf-with-dsym</string>
<key>EMBEDDED_PROFILE_NAME</key>
<string>embedded.mobileprovision</string>
<key>SDKROOT</key>
<string>iphoneos2.2.1</string>
<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>NO</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>NO</string>
</dict>

3. In xcode "Project Setting";
Code Signing Identity:Any iPhone OS Device=iPhone Developer

4. In xcode, execute "Build" not "Build and Go"

5. Connect iPhone

6. SFTP (root/apline) the app archieve (e.g. HelloWorld.app directory) to iPhone's
/Applications directory

7. SSH to iPhone

8. Execute the following in SSH

ldid -S /Applications/HelloWorld.app/HelloWorld
chmod +x /Applications/HelloWorld.app/HelloWorld

9. Use BossPref to respring

Congradulation, you shall be to run the program from your iPhone instead of the SDK's simulator.


Some other reference:
How to deploy an iphone application wihtout an IDP membership

Jailbreak iPhone for programming

My iPhone is a G2 version I bought from the State, I followed the iClarified note, upgraded to 2.2.1 and jailbreak it.
http://www.iclarified.com/entry/index.php?enid=1557

I found it was the most straight forward and for non technical users.