WPF Control Development Unleashed

Readers of the blog might think I am only working on iPhone stuff, but in fact I am programming WPF for 40 hours a week. I am glad, because C# / WPF is a lot better then Objective-C / Cocoa Touch.

WPF Control Development Unleashed

Last week I got the latest book of SAMS publishing about WPF. I did recommend the Windows Presentation Foundation Unleashed before, but now they have a new book. It’s called WPF Control Development Unleashed.

The previous book is still the best book out there, if you want to get started on WPF development. If you’re already an experienced WPF developer and develop your own WPF controls or use advanced layout scenarios, then the new book is for you. I am an experienced WPF developer (over two years 40 hours/week pure WPF programming), but there was enough in this book to pay $50 for it.

When you’re serious about WPF programming and think you know already a lot about it, then you should order this book right away.

Create applications for the iPhone

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:

Useful books

Title: Learn Objective-C on the Mac
Author: Mark Dalrymple & Scott Knaster
ISBN: 978-1-4302-1815-9

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
ISBN: 978-1-4302-2459-4

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!!!):

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:

  1. 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.
  2. 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:

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.


Bluetooth profile selector [jailbreak]

A little while back I described how to disable A2DP on your iPhone. It required manual modification of some files on the iPhone, which is not for the faint of heart. Now, I have created an application that allows you to change the Bluetooth profiles on a per-device basis. It works very easy.

Bluetooth device selectionBluetooth profilesAbout BTPS

Go to Cydia and look for the Bluetooth Profile Selector application. It is hosted with the BigBoss repository that is installed with Cydia by default. After installation you should see a red box with a Bluetooth icon inside of it.

The application shows all Bluetooth devices that have been detected. Just tap on one of the devices and the next screen is displayed that contains all the profiles that the iPhone can use on that device. The default setting enables all profiles, but you can choose which profiles that you want to enable. When you’re finished, just press the home button and the settings will be applied. During this process the Bluetooth server is restarted, so you’ll lose any active Bluetooth connections for a short while.

You can also download the package here. Put it on your iPhone and use SSH to run dpkg -i BTPS.deb to install it.

UPDATE: Apple has changed something in v4.3.1 and the profile selector cannot be used since then. Unfortunately, I don’t have an iPhone with v4.3.1, so I cannot test it. There has been some people that claim that they can fix it, so you can download the code here.

I received several requests from people if they could donate. You can donate via Paypal if you like:

Clean your mighty mouse

Apple’s Mighty Mouse is not so mighty after all. After some time, dirt will fill up the scrollwheel and you cannot scroll anymore. I did some cleaning by rubbing the wheel over a tissue with some cleaning fluids, but that didn’t work anymore after half a year.

I found this tutorial on the internet that tells you how to take apart your mouse and clean it good. It’s not for the faint of heart, and you will definitely make some scratches on the bottom ring, but you hardly see it after you put it back together. I didn’t use a chisel, but used a small house knive (use at your own risk).

Here are the complete instructions: