Archive for the 'Developer' Category

LoadBundles

Thursday, January 1st, 2009

FCS announces today new source code for an application called LoadBundles. LoadBundles is a small application and InputManager that makes it easy to load arbitrary bundles into specific applications. This is designed to be a developer’s tool in order to do basic hacking at applications. FCS uses this functionality to develop Applescript support for other applications.

Using git commit count as an incremental build numbering system

Saturday, October 11th, 2008

I’ve pretty much made a switch away from svn and towards git. It wasn’t easy. I loved svn and still know how to use it better than git. However, git just seems to work better for me as a single developer content management system. I’m still using svn for some of my projects (and whenever I’m ask to use it by a contractor) so it still has a place in my toolbox and in my heart. For nearly all of my new projects, however, I use git repositories.

Unfortunately, most of my other versioning tools are based on svn. I’ve been redoing them as necessary for a while but finally came to one that I must have now.

A while ago, I wrote on how to do better application versioning with svn. Basically, using the commit number of a subversion repository made it easier for me as a developer to figure out meaningful differences between versions of my application. If users reported a change between versions of an application, I would have some clue of what changed because I could compare revisions. Today, I decided that I absolutely needed this for git, too.

The problem is that git works with hashes instead of numbers. This isn’t a problem with git, it’s a problem with my system. However, it’s one that is easily remedied. git provides a lot of “porcelain” that makes it easy to build tools on top of tools. That’s essentially all I’ve done.

The first thing I do is set up a new “Run Shell Script” build phase in Xcode. Enter the following code as the script to run:

GIT="/opt/local/bin/git"
VERSION=`$GIT rev-list --all | wc -l | sed "s/[ \t]//g"`
defaults write $PROJECT_DIR/Info CFBundleVersion $VERSION
touch $PROJECT_DIR/Info.plist

Basically, we’re just getting a list of all of the revisions, getting the line count (using wc), and then stripping out all of the blank space (with sed). Then we use defaults to write the value to the Info.plist file directly. You may have to change the location of git depending on where you’ve installed it by changing the first line. I also like to touch any files that I’ve modified just to be sure that the files I’ve modified are clearly marked as changed.

Now, we’ve got the number of commits in our CFBundleVersion. The next problem is how to convert that into a meaningful git commit hash in case we need to compare commits. Well, I wrote a small Python script to handle it. That script gets all of the commits and prints the line that corresponds to the version number. Simple. You’ll have to install it in an executable location and also chmod +x it.

So now I have a basic incremental build numbering system to use in my applications that’s based on git. If you have any ideas on how I can improve this, please let me know.

Mixing Nu and Objective-C

Saturday, May 24th, 2008

It’s no secret that I’m a big fan of Nu, the new programming language based on Lisp and built on top of Cocoa. I’ve got a reasonable number of small projects and whatnot available that target Nu programmers. I’m also using Nu in Paperclip. I’m also playing around with Nu in other, private applications. I’m most excited about the ability to easily mix Nu and Objective-C in the same project. Today and yesterday, I decided to try to integrate the two in one project from the very beginning. Basically, anything written in Nu is just as available to the run time as anything written in Objective-C. It’s a bit of a chore and requires a bit of setup but it can be done. I’ve provided step-by-step instructions as well as lots and lots of screenshots.

[UPDATE] Following the advice of Drew in the comments, I’ve created a Cocoa-Nu template available for download. It can be found on my github account. A tarball can be download here. (more…)

NuTitleCase

Thursday, May 22nd, 2008

A few days ago, John Gruber released some Perl code called Title Case. Title Case provides semi-intelligent title casing. It can convert strings into standard title format including capitalizing all words except for common words (such as articles and conjunctions) as well as the first and last words of titles.

Since I’ve already converted other Gruber projects to Nu (such as Markdown and SmartyPants), I went ahead and translated this, too. The source code for NuTitleCase is available on github.

Turn an Apple Event into an NSDictionary

Monday, April 21st, 2008

I ran into an issue developing the latest version of Paperclip (1.4.1 as of this writing) involving applescript. Basically, you cannot send an applescript record to an application. It throws a massive error saying that it can’t convert to the Cocoa equivalent, NSDictionary. To an extend, this isn’t unreasonable. Since dictionaries can basically hold any content and since the keys could be applescript types or keywords (for which there really isn’t any way to translate to Cocoa), it seems prudent to Apple to not allow this.

Unfortunately, that isn’t good enough for me. I wanted better so I wrote it. Paperclip 1.4.1 and later includes an applescript front-end to a Nu parser. This front-end includes the ability to drop objects into the Nu code’s active context by passing a record (hence my need to convert an applescript record into an NSDictionary).

This part of my code, every last usable bit, has been made available as open source. ApplescriptToDictionaryWithNuToo is an example application that demonstrates using applescript as a front-end to Nu.