I have been writing Ruby applications exclusively for awhile now, so I thought it is time to try out something new. As a result, I have developed an OSX Cocoa application for hallenprojekt.de, a website that aggregates different co working spaces. It is an application that lives in the status bar and allows easy checking into the available co working spaces.
It was fun and sometimes painful to learn how to achieve things with Objective-C and Cocoa in particular. And of course, learn how to automate packaging and deployment of new releases including automatic updates. Ironically, I ended up doing most of those tasks with Ruby. I will write a few blog posts covering my endeavors.
The source is available on github and the application itself can be downloaded here.
As part of the automated deployment process for a cocoa application, I needed to access a .plist file to change some values before the application gets bundled and uploaded.
Since plist files are plain XML files, I could have used something like libxml to get the job done but since this script runs on a Mac, I have access to RubyCocoa. That spares me the XML parsing and writing and gives me a simple persistent dictionary instead. This is what I ended up with:
I think that is pretty neat. However, I ran into a small pitfall when I tried to compare an NSString with a regular expression. I got this warning:
'NSString#=~' doesn't work correctly. Because it returns byte indexes.
Please use 'String#=~' instead.
The solution is pretty simple, just call to_s on the dictionary values.