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.