Side Projects

Sorry for the dead air over the last few months. Things got a bit hectic at my job and I couldn’t seem to find the free time to post. On the plus side, things are starting to calm down. We’ve shipped some more software and I’m finally catching up with some side projects.

One project which I started at the March CocoaHead Hackday is GoldCards. It’s an iOS reference tool for Hearthstone.

  • GoldCards Screenshot 1
  • GoldCards Screenshot 2
  • GoldCards Screenshot 3
  • GoldCards Screenshot 4
  • GoldCards Screenshot 5
  • GoldCards Screenshot 6

While I want this to be a Universal (iPhone and iPad) app in time I think I’m going to finish up a few more loose ends and release it as an iPhone-only app for now.

Another big side project is CocoaLove, an iOS-focused conference coming to Philly. I’m on the planning committee (sponsorship and AV to be specific). I’d also like to help build a simple conference app with the schedule and what not. Shouldn’t be too hard considering my history with such things.

In addition to all that I’m also trying to catch up with some web tech, Ember and Node to be precise. There are a few things on my idea board that could utilize such skills so I’m taking some time reading books and going through Code School examples to catch up.

iOS Development: Things to Like; Things to Hate

Things I like about iOS Development

  • I like writing code in the Objective-C language.
  • I like Apple’s provided frameworks and tools. They are, on the whole, very good.
  • I like the iOS community’s enthusiasm for great products. It is very inspiring.
  • I like that people will pay you good money to build apps for them in iOS. Though this is has good and bad implications.
  • I love attending, and over the last few years running, CocoaHeads in Philadelphia.
  • I like that the community on a whole is not very secretive. There is a sense we are in this together and people constantly help each other out sharing tips, code and war stories.

Things I hate about iOS Development

  • I hate the exclusivity of the AppStore distribution.
  • I hate that I can’t side load apps that people build that Apple doesn’t approve of.
  • I hate that I have to sign my apps.
  • I hate the learning curve and the bugs of the signing process for all but especially for people new to iOS.
  • I hate that Apple has a shitty code validator during app signing that will complain when I have methods on my objects that look like private methods on their objects.
  • I hate how shitty AppStore search and discovery is.
  • I hate the corporate politics that let apps get featured in the store because of “connections”.
  • I hate how people continue to manipulate the AppStore ranking system and I hate how little Apple seems improve the situation when many small developers livelihoods are at stake.
  • I hate how the Radar bug system doesn’t have tools in place to involve and update the original bug reporter on progress being made. From a third-party perspective most bug reports might as well go into a black hole.
  • I hate how in the pit of my stomach I believe that, on the whole, the iPhone and its brethren have not improved society. I think the majority of mobile software has only helped to empower “generation ‘me’”, a generation that is “friends” with everyone, but no one. This deserves a post on to itself someday.
  • I hate the iOS / Mobile bubble. The fact that people are spending way too much building apps and are not getting a proper return of value on the investment.
  • I hate that building products is way riskier than consulting (bubble related).
  • I hate that Apple hasn’t shown more interest in providing a library management system. Thankfully we have CocoaPods but since it’s on the outside there is a fear it might not be able to keep up as the tool chain evolves.
  • I hate that back when Apple first started to integrate OCUnit into Xcode it enviably killed like 3 or 4 other very promising testing systems because the thought at the time was “well Apple made their choice and will build on it” when in fact Apple never did. Only recently did we see XCTest and it is, right now from a functional perspective, a method renamed version of OCUnit with no new features.
  • I hate how Xcode Bots doesn’t have pre and post scripts.
  • I hate (hate is a strong word — let’s say disappointed by) the growing community of “Apple Celebrity”. The once full time developers who can build great things but now choose to spend the majority of their time blogging, podcasting and tweeting all day. They partake in a low impact ping pong match of opinions on weekly events and news that frankly doesn’t mean all that much in the grand scheme of things.

MegaManEffect now on GitHub

A few days ago I started to archive a lot of the Clickable Bliss website, replacing it with a smaller “hiatus” version. In the process I moved the MegaManEffect which lived primarily via a blog post and a GoogleCode subversion repo to GitHub.

https://github.com/zorn/MegaManEffect

The MegaManEffect is an application that emulates an effect seen in the classic NES game Mega Man 2. When you launch a Mac OS X application, the screen goes dark, stars sweep the night sky and your application’s icon is presented in a blue letter box bar with a cheesy 8-bit music introduction.

MegaManEffect was written while I attended the ADHOC/MacHack conference in 2004 and took second place in the ADHOC Labs Showcase! In the summer of 2005 the application hit a nerve in the community generating tons of interest and downloads. It is to this day one of the most distributed pieces of code I’ve even written.

Funny enough after tweeting the move I ended up getting an email and later a pull request to update the code base to compile on 10.9. I approved the pull request today (thanks @smithrobs!) with a few other fixes.

The MegaManEffect will be 10 years old this summer.

Enums and Switches

If you are one to use enum to define modes or types in your models or controllers, consider using switch statements to help branch the different behaviors. If you do so, the complier will help you when you have forgotten to implement behavior for a enum value.

Take for example a view controller that might have different behavior if we are in an editing mode, and even more so the editing is handled differently depending on the target device. For this, let’s create an enum like:

typedef enum ViewControllerMode : NSUInteger {
    ViewControllerModeDefault = 0,
    ViewControllerModeEditingiPhone,
    ViewControllerModeEditingiPad,
} ViewControllerMode;

Now if the tableView:didSelectRowAtIndexPath: method let’s use a switch statement to branch behavior depending on the behaviorMode.

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (self.behaviorMode) {
        case ViewControllerModeDefault:
            [self showRecordAtIndexPath:indexPath];
            break;
        case ViewControllerModeEditingiPhone:
            [self editRecordAtIndexPath:indexPath];
            break;
        case ViewControllerModeEditingiPad:
            [self replaceRecordAtIndexPath:indexPath];
            break;
    }
}

Notice we are not using a switch default behavior here. Now let’s add a new enum type called ViewControllerModeEditingiWatch and compile. Tada! The complier has a warning for us.

Enumeration value 'ViewControllerModeEditingiWatch' not handled in switch

This pattern can be extremely helpful to make sure you are accounting for all needed behaviors. Please consider it next time you are working with enum. Thanks!

Setup Bots Status as a Screensaver

It’s time to turn off that family photo screensaver and switch to something that’s important, CI status screens!

Bots Big Screen

First up you’ll need this screensaver (or something similar), which can be configured to load a single or multiple websites up as a screensaver.

https://github.com/liquidx/webviewscreensaver

Sadly the screensaver bundle is not developer signed so if you are bit paranoid consider downloading, inspecting and building the thing from source. Or you could be like me and hit run inside of Security after the initial “can’t run, not signed” dialogue.

Next you’ll need some URLs. I run both Xcode Bots and Jenkins off my Mac mini named GLaDOS and for those you’ll want URLs like:

http://glados.local/xcode/bigscreen

http://glados.local:8080/view/Monitor/

For Jenkins I’m currently using the Build Monitor Plugin which is pretty basic but a nice start.

Here’s to hoping all your returns from coffee breaks are bathed in green and passing tests.

Xcode Bots and Branches

Just a little quick tip tonight. If you create a Bot from within Xcode 5 it will assume that the branch you want this Bot to run on is the branch you are currently on. To change this, use the Xcode Bot Web interface. Select your Bot and look for the settings gear in the upper right and then edit the Bot, defining which branch you want to bot to run on.

Xcode Bot Setting Gear

Xcode Bot Setting Details

I’m starting to revive an old side project of mine and it’s feeling good so far. I have Xcode Bots running tests and the static analyzer (all green baby!). I also have Jenkins deploying to HockeyApp when I merge development into my qa branch. Hope to share more details soon.

Podcast Idea

A podcast idea…

Introducing Merge Conflicts a Cocoa focused debate podcast where people argue for or against different systems / programming patterns. There is a central, ever repeating host who moderates the debate and two guests who argue for either side. Some show ideas include:

  • Core Data vs. Custom SQL
  • Storyboards vs. XIBs
  • Git vs. Mercurial
  • Homebrew vs. MacPorts
  • CocoaPods vs. Manual Code Sharing
  • AppCode vs. Xcode
  • Code generators (like mogenerator) Love Them vs Hate Them
  • TestFlight vs. HockeyApp
  • Kiwi vs. XCTests
  • Retain vs. Release
  • And so on…

Thoughts? Let me know via email or the twitters @zorn.

IBOutletCollection

Did a short show and tell at the last CocoaHeads meeting demoing something I learned at work and hadn’t known about before, that being IBOutletCollections.

For seasoned Cocoa developers we all know that an IBAction is typically how a button sends a message to the controller that something should happen. On the flip side there is IBOutlet which is a pointer to a view in the UI that let’s the controller have access, typically to update the view’s contents or attributes.

Well an IBOutletCollection lets you have access to a whole collection of views via a single connection. In code declaring an IBOutletCollection is going to look something like this:

@property (strong, nonatomic) IBOutletCollection(UITextField) NSSet *textFields;

When you declare the type of the outlet you can be specific such as UITextField or use higher level classes like UIView and connect to many different kinds of views. Technically you can use NSArray but since the order isn’t something I think is guaranteed best to stick to NSSet. Finally, while most outlets should be using weak references, these use strong since the view controller needs to own the array that contains the connections.

When you want to iterate over the collection just use fast enumeration like you normally would with an NSSet.

- (void)updateUI
{
    for (UITextField *textField in self.textFields) {
        textField.text = self.mainTextField.text;
        if (self.isBlue) {
            textField.textColor = self.view.window.tintColor;
        } else {
            textField.textColor = [UIColor redColor];
        }
    }
}

For a simple project demo see my OutletDemo project on GitHub.

Some real world use cases for IBOutletCollection might include theming (outlet collections for various styles, then making connections to view that should be styled) as well as form access and validation. IBOutletCollection was introduced in iOS 4 so theres no reason not to check it out. Enjoy.

Updating Homebrew’s “httpListenAddress” Default for Jenkins

I’ve setup some Jenkins servers in the past for Ruby on Rails apps but these days we are trying to get things running for iOS deployment and testing at work.

To experiment with some plugins and such I have my own Mac mini and installed Jenkins via Homebrew. Overall it’s working great though I was a bit stumped as to why I couldn’t load the Jenkins webpages outside of using localhost:8080 on the Mac mini itself. Worked fine last I did a clean install.

Turns out the Launch Agent settings Homebrew gives you (located at ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist for me) will launch with the following command line parameter --httpListenAddress=127.0.0.1. Edit this to 0.0.0.0 (the default) to allow all addresses.

I know this isn’t the most enjoyable blog post but wanted to post it as Google Food for others who might run into the issue.

Other related posts:

My New Job with DmgCtrl

After almost eight years of self-employment I have decided to jump back in and as of Monday started a new job working at Damage Control (DmgCtrl) here in Philadelphia.

DmgCtrl Logo

I would suspect most people (especially those outside Philly) will not know the name DmgCtrl and that is kind of intended. The founders Jason Allum and Mac Morgan have never really put much energy in advertising their “brand” and have let their work and client happiness speak for itself. Mac once said:

Do great work and everything sorts itself out. We don’t advertise (you can see from how sparse our website is) and rarely have to even pitch work, people find out about us entirely through word of mouth. So keep your eye on quality. Everything else is a distraction.

I’ve known DmgCtrl through IndyHall and Jason for years and there is really a lot of great things going on here. This isn’t a strait-up “Platform X” development shop. The projects aren’t limited to a single tech stack nor are the employees abilities. Diverse backgrounds are common and education seems to be a core part of the culture.

It may sound trite, but one of things I really came to love about working on Shindig was the benefits of being on a development team. I loved getting feedback via code review; I loved brainstorming ideas over lunch. Going back to contracting, doing 1-man projects all on my own, I felt like I was missing out, like I’m not growing as a programmer as much as I could.

Anyways, I’m really looking forward to working at DmgCtrl. There are a bunch of interesting things in the pipeline, some I might even be able to talk about someday. :)