I little while ago I figured out how to disable A2DP on my iPhone. It requires some changes to property lists, which requires additional tooling and makes it less accessible to less experienced users. If it was a Windows based device, then I would have created an application to make the changes. So why not do this for the iPhone?
The iPhone also has a compiler and SDK, but it uses the Objective C language and the Cocoa Touch framework. I am used to Windows programming for the last 15 years and I can tell you that iPhone development is completely different. I bought two books that got me started on Objective C and iPhone development:
Title: Learn Objective-C on the Mac
Author: Mark Dalrymple & Scott Knaster
This book describes all the aspects of Objective-C. I think it is a little verbose and when you already familiar with object-oriented programming, then you probably want to skip a lot of details. I bought it, because I wanted to make sure I didn’t miss anything. Make sure you know Objective-C, because it’s not just a different C++ dialect.
Title: Beginning iPhone 3 Development: Exploring the iPhone SDK
Author: Dave Mark & Jeff LaMarche
I first downloaded a PDF version of this book via a torrent site and liked it so much that I decided to buy the (updated) paper version of the book. It describes iPhone development from the ground up, so it’s a good starter for iPhone development. It describes all the common controls and views that are used in iPhone applications. I am not a Cocoa expert, but I think that if you are then this book is not for you and you should look for a bit more in-depth book.
Get the right tools
Developing iPhone applications is only possible on Mac OS X, so you need an Apple computer. The standard development environment is called Xcode. You need to obtain an Apple Developer Connection membership to be able to download Xcode. The online membership is free, so make sure you register.
Once you have been registered, then you should download and install Xcode. Make sure you download the right version. If you are running OS X v10.5 you need to download Xcode v3.1.x. Snow Leopard users (OS X v10.6) need Xcode v3.2.x. This is all you need to develop software for Mac OS X, but it doesn’t contain the iPhone bits. Go to the iPhone section on the developer website and download the iPhone SDK.
This is all you need to create iPhone applications and test the applications in the iPhone simulator.
Test application on your own iPhone
Once you are ready developing and testing your application in the simulator, then you need to test it on your own iPhone. You can enroll in the iPhone Developer Program, which will cost you at least $99. If you plan to put the application in Apple’s AppStore, then you need to do this. There is no other way to get your application in the AppStore.
My application will not be approved in the AppStore, because it changes system settings and this is not allowed or possible from applications in the AppStore. My application will be distributed via Cydia (only for jailbroken iPhones). You don’t need to enroll for the iPhone Developer Program, but you need to make some modifications to your Xcode installation to make sure you can sign your application.
Obtain a code signing identity
You need to obtain a code signing identity. Fire up Keychain Access and choose Keychain Access – Certificate Assistant – Create a certificate… and use the following settings:
Note that you create a certificate with the name iPhone developer for code signing and you want to override defaults. Click continue and accept the defaults (although you can change your email address). Make sure the certificate is stored in your login keychain.
Patch Xcode v3.2 to deploy
There are two ways to patch Xcode to allow the application to be build. This first method is to patch Xcode v3.2 to be able to sign applications without a provisioning profile (note that this patch is only valid for v3.2!!!):
#!/bin/bash cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS/ dd if=iPhoneOS\ Build\ System\ Support of=working bs=1 count=300752 printf "\xc8\x2f\x00\x00" >> working dd if=iPhoneOS\ Build\ System\ Support of=working bs=1 skip=300756 seek=300756 /bin/mv -n iPhoneOS\ Build\ System\ Support iPhoneOS\ Build\ System\ Support.original /bin/mv working iPhoneOS\ Build\ System\ Support chmod a+x iPhoneOS\ Build\ System\ Support
Another approach seems more elegant. Create a backup of /Developer/Platforms/iPhoneOS.platform/Info.plist and modify the Info.plist by replacing the two occurrences of XCiPhoneOSCodeSignContext with XCCodeSignContext.
Update project settings for code signing
Application signing Project – Edit Project Settings, select the Build tab and find the Code signing section. Select the Code Signing Identity. At the lower left part of the dialog, there is a popup menu and you should select the Add Build Setting Condition. Change the Any SDK to Device – iPhone OS 3.0. Select the iPhone developer certificate in the right column. If it doesn’t show up, then you didn’t create a proper certificate. The screen below shows the correct settings:
Sign your application
Applications on the iPhone need to be signed. You can use the official Apple signing method, which is pretty complicated, or use Saurik’s pseudo-signing method. In this tutorial I will use the pseudo-signing, because it’s easy and codesign checking has been hacked out of the jailbroken kernels anyway. There are two ways to pseudo-sign your application:
- Sign the applications on the iPhone itself. SSH to your iPhone and run apt-get install ldid. This will install the ldid utility in the /usr/bin directory. After you have copied your executable to the iPhone, then you need to run ldid -S <ProgramName>. This will sign the application, so you can run it.
- Sign the application on your Mac. Download ldid from TheBigBoss site to /usr/bin. Make sure that you can execute it (chmod 755 /usr/bin/ldid). Make sure you sign you applications at the end of the build process. In XCode select Project – New Build Phase – New Run Script Build Phase and use the following script:
/usr/bin/ldid -S $TARGET_BUILD_DIR/$TARGET_NAME.app/$TARGET_NAME
If you forget to sign the application, then your application will crash immediately after starting.
Create a deployment package
I could have copied the text on Saurik’s website, but if you look here then you find everything that you need to create packages to deploy you application. After transferring the package to your iPhone, then you can install it using dpkg -i package.deb. You need to refresh your springboard to make sure the application is shown on screen. I use gUICache (available through Cydia) to refresh. Cydia refreshes automatically, after you (un)install a package.
Submit the application to a repository
When your application is ready, then you probably want to release it. You need to host the application via a repository, such as TheBigBoss.org. This repository is available in most Cydia configurations, so you are sure that users with a jailbroken iPhone can find your application. You need to have a Debian compliant package and need to fill in a form. The application will be hosted in the repository within 24 hours.
- Telesphoreo Tangelo is the base of the APT-based repository that Cydia uses. This package also contains the source of ldid.
- Saurik’s website is the home of Saurik that developed Cydia and is a great source for iPhone development. He has a good article about code signing, creating packages for Cydia.
- The title Compiling iPhoneOS (3.1) apps with Xcode 3.2 without Provisioning Profile says it all.