a.k.a devgeeks

Software development in the minutes a day I have spare

Finally submitted

It’s been almost two months since my last post, but that’s because I have been working hard on a new app. In fact, an entire new product.

I’ll be able to post more soon including some of the custom plugins I wrote for the app.

It’s a camera-based app at heart so I needed a custom camera overlay view as well as some changes to make the camera more responsive (there was a horrible delay after clicking the “use” button in the core PhoneGap Camera API).

I am hoping to find a way to make the camera functionality open source and abstract enough that it would be useful to someone else.

Until then, stay tuned? ;)

The PhoneGap installer for iOS overwrites the old version when you run it. It puts itself in over the top of your previous version.

However, when you have shipped an app with PhoneGap and it’s happily in the App Store, the last thing you want to do is have to deal with changes in the PhoneGap API between versions if you need to make small maintenance tweaks down the track. 

Here’s what I do in this instance.

  1. Before upgrading PhoneGap (running the installer) I back up the previous version of the framework. I copy ‘/Users/Shared/PhoneGap’ to ‘/Users/Shared/PhoneGap-<version>’ (such as ‘/Users/Shared/PhoneGap-1.2’).
  2. Next I go into the projects that I want to keep running that version, and I delete the PhoneGap.framework from the project (remove reference only). 
  3. Then I add the framework from the copied versioned folder I made in step #1. Select the target in Xcode, choose the “Build Phases” tab, open the “Link Binary With Libraries” section and click the + and choose “Add Other…”, browse to where you backed up your old PhoneGap.framework and add it in.
  4. Upgrade PhoneGap to latest version.

You now not only have a back up you can keep old projects maintained against, but you have a version you can use if the new PhoneGap changes something you want to use or breaks a plugin you need for your project. In fact, inside the ‘/Users/Shared/PhoneGap-1.2/Frameworks/PhoneGap.framework/www’ folder is the version-specific PhoneGap iOS JavaScript file if you need to downgrade a project.

It’s that time again. Time to update the 4ZzZfm iPhone app. Actually, it’s way past due… but this is the way things go sometimes.

Early on I attempted to use some of the “write your app in HTML/Javascript/CSS and deploy to iPhone” technologies, but at the time their acceptability by Apple for App Store distribution was in doubt, and I couldn’t get them to do what I wanted anyway. This meant I had to actually learn Objetive-C. Now let me just say that I really like Objective-C. The problem is that I am primarily a PHP developer so HTML/JavaScript/CSS feels more natural to me.

This has lead me to revisit the above-mentioned web technology options for iPhone app development. PhoneGap in particular seems to be both quite mature, used a great deal in apps in the App Store and quite extendable via plugins. This last part is the bit that has tipped it for me. Not only are there some great plugins available for PhoneGap, but it is quite easy to write your own plugins.

What this all comes down to is that I am going to try and re-write the 4ZzZfm iPhone app using PhoneGap and write whatever plugins I need along the way that aren’t catered for in PhoneGap’s core or plugins written by others.

I have already started on this process and I have the Audio Streaming classes written by the amazing Matt Gallagher (cocoawithlove.com) that I used in the original Objective-C version of the app (mostly) working as a PhoneGap plugin. The remote control events don’t work yet, and I am not sure that will be possible from a plugin anyway… that might require some hacking of the PhoneGap core. We’ll see. It needs some more work update: I have had the remote control events working fine. No core hacking needed. Then between updating PhoneGap and iOS something went wrong.

Another piece of functionality I need for the 4ZzZfm iPhone app is a volume control slider. In the Objective-C iPhone SDK that is implemented using an MPVolumeView (from the MediaPlayer framework).  This turned out to be a very easy to make into a PhoneGap plugin. Now one of the best things about PhoneGap is that it and its plugins are open source. PhoneGap and its plugins are developed by the PhoneGap community and available on GitHub. So I have decided to join GitHub myself and submit any plugins I create for this project that I think others might find useful. The first of these that have been added to the main PhoneGap plugins repository is the aforementioned VolumeSlider plugin. I am pleased as punch about this as it is my first real contribution to a modern open source project. Hopefully it is just the first of many more such contributions.

Wish me luck. Worst case I can always just stick with Objective-C.