Thoughts on mobile app development.

Using Cocos2D in a UIKit project

I recently needed to add a “water ripple” effect to a project. Although there is a simple water ripple effect built-in to the SDK, it really didn’t fill my needs. It seemed like my only options would be to quickly boost my OpenGL skills (from none to something), or find an alternative. I soon found a really nice water ripple effect built for Cocos2D, which was exactly what I wanted. The only stumbling block was how to integrate Cocos2D into my existing UIKit project. As it turns out, it’s fairly simple.

First, download the source for Cocos2D. If your UIKit project is using ARC, you’ll need to download the “bleeding edge” version from GitHub, as this is currently the only version in which the header files are all ARC friendly. If you are not using ARC, the latest stable version should be fine (currently v1.0.1). Once you have the Cocos2D source, locate the file “cocos2d-ios.xcodeproj”. Open up your UIKit project, and drag this file into your file navigator. You should end up with something like this:

Next, go to the Build Phases settings for your project, and add the Cocos2D library (libcocos2d.a) as a linked library. You’ll probably also need to add OpenGLES.framework, and libz.dylib, like so:

You’ll also need to modify your Build Settings. Set Always Search User Paths to YES, and add the Cocos2D source directory to the User Header Search Paths (as a recursive path):

At this point, you should be able to import the “cocos2d.h” header into one of your source files, and compile your project. If you are using ARC and get some build errors, make sure your Cocos2D source is the development (bleeding edge) branch. Even though Cocos2D itself is not ARC enabled, it’s no problem to combine it with an ARC enabled project, provided you are using the correct version.

Now that Cocos2D is part of your project, it’s time to write some code. I only needed Cocos2D in one small part of my application, so I decided to limit it to a single UIViewController. This is the code that I used:

- (void)viewDidLoad {
[super viewDidLoad];

CCScene *introScene = [CCScene node];
self.introLayer = [IntroLayer node];
[introScene addChild:self.introLayer];

if(![CCDirector setDirectorType:kCCDirectorTypeDisplayLink]) {
[CCDirector setDirectorType:kCCDirectorTypeDefault];

CCDirector *director = [CCDirector sharedDirector];
EAGLView *glView = [EAGLView viewWithFrame:CGRectMake(0, 0, 1024, 768)
pixelFormat:kEAGLColorFormatRGB565 depthFormat:0];
[director setOpenGLView:glView];
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
[director setAnimationInterval:1.0/60];
[self setView:glView];
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGB565];
[[CCDirector sharedDirector] runWithScene:introScene];

[self.introLayer setupScene];

- (void)runRippleAnimation {
[self.introLayer runRippleAnimation];

- (void)endRippleAnimation {
CCDirector* director = [CCDirector sharedDirector];
[director end];

I won’t go through the details of how to create a CCScene and CCLayer – there’s plenty of Cocos2D tutorials out there. The code that you’ll be most interested in is this:

if(![CCDirector setDirectorType:kCCDirectorTypeDisplayLink]) {
[CCDirector setDirectorType:kCCDirectorTypeDefault];

CCDirector *director = [CCDirector sharedDirector];
EAGLView *glView = [EAGLView viewWithFrame:CGRectMake(0, 0, 1024, 768)
pixelFormat:kEAGLColorFormatRGB565 depthFormat:0];
[director setOpenGLView:glView];
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
[director setAnimationInterval:1.0/60];
[self setView:glView];
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGB565];
[[CCDirector sharedDirector] runWithScene:introScene];

This basically sets up the Cocos2D environment, and starts running your CCScene. And that’s it! I presented this UIViewController modally, but I expect you should be able to use this method within a subview just as easily.

Combining UIKit and Cocos2D does suffer a performance hit, but I’m not doing anything overly complex here, so it wasn’t a problem. I’m also not sure if this is entirely the correct way to do things, but again – it works, so I’m happy.

Cocos2D has a heap of really nice effects, with a great community behind it. If you need some extra pizazz in your app, it might just be the way to go.

What I Did For Every Minute Of 2011

As detailed in a previous post, one of my goals for 2011 was to get a better idea of what I was spending my time on. It’s always easy to feel like a certain project has dragged on or taken up more time than it should, but you never really know the truth – unless you actually keep track. I spent all of 2011 by recording what project I was working on, when I worked on it, and for how long. As a result, I now have a good idea of what’s taking up too much time, what I should spend more time on, what’s bringing in a good amount of income, and so on. I found all these details pretty interesting, perhaps you will too.

Hours Per Week

This was one of the first things I looked at – total hours worked in 2011, and how that worked out as an average per week. It turns out that I worked an average of 31.2 hours a week in 2011. The standard Australian work week is 38 hours, so I was pretty happy with this. Those 31.2 hours were spent doing real work – anytime I opened up Facebook or read the news, I stopped the timer. This average also includes holidays, days off, etc. I dare say that I’m working more real hours than the average Australian, but I’m also working more efficiently. Recording what I’m working on and for how long has really helped me cut down on wasted time spent pretending to be working, or waiting until 5pm rolls around. If I can churn out the same amount of work in less time than the average employee, that’s a win in my book.

Hours Worked – In-House vs Contract

The primary reason I started tracking my time was that I wanted to split my time 50/50 between contract and in-house app development. I’ve always felt that although I enjoy in-house app development the most, this got pushed aside for contract work, especially when deadlines were approaching. I ended up spending 38% of my time on in-house apps, so while I didn’t quite achieve my goal, this was actually more than I expected.

Hourly Rate – In-House vs Contract

The really interesting part of this exercise for me was to be able to compare income gained from different sources, and how that converts to an real hourly rate. Though I generally charge a fixed price for all contract jobs, this is still based off an hourly rate. Being able to see how long a project actually took gives a really solid picture on how good you are at estimating time required, which clients are too demanding of your time, and projected income for the future. One satisfying thing I found was that by the hour, I earned pretty much the same amount on contract jobs as I did for in-house apps. In my opinion this is a pretty good justification for turning down contract jobs if I wish to concentrate on in-house work.

iPhone and Android

Though I’m not an Android developer myself, I have outsourced a few projects. Outsourcing isn’t free, and it also comes with a number of overheads – managing the process, explaining how the projects work, documentation, answering questions – it all takes time. As raw data, it looks like I actually earned about 60% more per hour from outsourcing projects than I did by developing the iOS counterparts myself. However, once I include the actual development costs of outsourcing, this figure drops dramatically. It turns out doing things myself might still be the way to go.

Keeping track of how I spent my time has turned out to be invaluable. It took very little effort, and has given me a real insight into my business. I’ll certainly be continuing the process for 2012 and beyond.

Statistics Never Lie

One of my goals at the start of 2011 was to spend 50% of my time on in-house projects. This is an area of my business that I really want to grow, and I find that I often give too much priority to contract work, whilst my own apps get pushed to the side. It quickly occurred to me that the only way I was really going to know where my time was going would be to track what I was doing, for every minute I was at work.

Keep track of everything, you say? That’s crazy! Don’t worry, I hear you, and it did take a little getting used to. However, it’s really not that hard, and I believe the benefits are many. But we’ll get to that.

The software I use is called On The Job. You start off by defining a client (eg. myself), a project (eg. an app), and a task (eg. v1.1 update). You then hit the record button and get to work! Whenever you stop working, you hit the stop button – easy. In case you forget to hit stop, the app also has a timeout feature, where if you stop using your computer for a few minutes, it will throw up a prompt and ask what you’d like to do.

So what actually counts as work worth recording? The main thing I think is that it’s important to be honest. If I’m not sure, I pretend for a minute that I have a boss who has just come up become me unannounced – would he think I was working or slacking off? If I open up Facebook, I stop the timer. Reading blogs doesn’t count either, unless it’s for a specific purpose. If I’m on the phone with a client though, it’s all recordable – even if we’re just having a chat. For me, this counts as client interaction time. If I head out of the office for a meeting, I count the meeting time, but not the travel time – unless I’m working off my laptop on the train. Food breaks, toilet breaks, afternoon naps – all timer stoppers!

But why bother? That’s a lot of timer stopping and starting throughout the day. Now that I’ve been doing it for almost a whole year, I have some solid statistics about what I spend my day doing. I can see exactly how long I spend replying to support emails, chatting to clients, doing paperwork, and creating apps. I think it also helps to keep yourself focused – if I’m working on a particular task and an interruption occurs (eg. an email arrives), I’m much more likely to ignore the interruption, as I’m recording time against the first task. Where this gets really interesting though is comparing the hours to income – I can now see what my real income per hour/client is, and compare this to in-house development as well. Every client has overheads which you can’t charge for, so it’s very handy to see which clients have more overhead than others.

I think this post is getting long enough, so I’ll save some actual figures for next time. The new year is fast approaching though, so think about giving this a shot for 2012. It’s a fairly easy habit to get into, and you’ll gain a much better understanding of you, your business, and where you should focus your time.

Is there still room for a Lite version?

A few months ago I released an app called Photo Academy. This app aims to help any photographer take better photos, by offering a large amount of tips, sample photos, and camera settings. Soon after release it was featured by Apple in the App Store, spent some time in the overall top 50 charts, and received a nice amount of positive press. Overall, I was very happy with how it all went.

As is usually the case, Photo Academy has dropped off the main charts, and has settled down into bringing in lower, but fairly decent and consistent sales. I’m certainly not unhappy with the income, but I enjoy the business side of iOS development, and business means making more sales. Almost anyone who makes apps is generally seeking out the answer to the age old question – how can I get my app into the hands of more users?

When the App Store was first opened to third party developers, the first answer to that question reared it’s head almost immediately – the “race to the bottom”. All of a sudden we were in a world where quality software was being sold for the bare minimum, a measly 99 cents.

It wasn’t long before the next strategy became commonplace – the Lite version. Developers would release two versions of their app, the full paid version, and the free cut-down version. All of a sudden we were in a world where you could try out the app for free, and upgrade to the full version for a measly 99 cents.

Fast forward to today, and freemium rules the App Store. Today we live in a world where you can try out the app for free, use it as much as you want, and if you’re really keen, buy a few add-ons for a measly 99 cents. But only if you’re really keen.

The future is anyone’s guess, but I wouldn’t be too surprised if Apple one day introduces full version trials, at least in the Mac App Store.

So where does this leave Photo Academy and me? Although I priced it at 99c for a small period of time, Photo Academy is now priced at $2.99, and I’m unlikely to ever drop the price again. I stand behind my product and believe it to be of a high enough quality to justify this price as a minimum. I also don’t believe the app is well suited to the freemium market – I think you need mass appeal to be a success in that arena.

This leaves us with the Lite version. The problem is, Lite versions always seem so tacky. Too many restrictions, ugly icons covered in messages proclaiming their free-ness, and user content which doesn’t transfer to the full version. As you may have guessed, I’m releasing a lite version of Photo Academy in the near future, but I wanted to reduce that icky feeling – I want my users to be just as pleased than if they had paid for the full version. Here’s the things I did a bit differently:

  1. I named the app “Photo Academy: Orientation”. This fits in well with the educational theme, and doesn’t scream “hey I’ve got a cut-down feature set!”. It also means users won’t be stuck with an app called “something something lite” on their phone, even after upgrading.

  2. I chose an icon which looks just as nice as the original:
    Photo Academy IconPhoto Academy Photo Academy: Orientation IconPhoto Academy: Orientation
  3. I gave users an easy upgrade path. They can unlock full functionality right within the app, without needing to download the full version from the App Store. All user content and settings naturally remain without needing to be transferred, and users aren’t left with an app covered in Lite stickers.

  4. I’m overly generous with the amount of content. Using analytics from the full version, I can determine which are the most popular sections of the app – and I give a decent amount of them away for free.

  5. As well as upgrading to the full version, I also allow users to purchase only the items they’re interested in (yes, for a measly 99 cents).

So is there still room for a Lite version? I think so. People like myself will just buy the full version straight away, while those who are a little more cautious now have some options as well. I’ll report back to let you know how it goes.

Photo Academy: Orientation launches on December 15, 2011.

A Healthy Indie Life

For the past 2.5 years, I’ve been working from home as an independent iOS developer. My real love is for developing in-house apps, but there’s a lot of satisfaction to be gained from freelance work as well. It took me a long time to get used to working from home, rather than working in an office. I’ve always loved the work that I do, and having the freedom to choose what that work will be, but working out of a spare bedroom on your own is a big shift. That said, I’ve been feeling increasingly happier with my situation over the past 6 months or so, and I’d like to share a few of the reasons why I think that is.


I personally think this one is so important that it comes first – both in this blog post, and in my day. Every morning I wake up at 6.30am, and head off to a CrossFit session. I’ve tried a lot of things in the past, but I absolutely love CrossFit. Sessions are typically run by a trainer with a group, and usually involve a high-intensity workout with a variety of exercises (we even get to do handstands). The beauty of it is that everything can be scaled, so it really doesn’t matter how fit (or unfit) you are. Now that I’ve been doing this for a few months, not only do I feel great, but I’ve made some new friends, it gets me out of the house, and no matter what else happens for the rest of the day, I can at least feel good about having done some exercise. Of course, you don’t have to join a CrossFit group to get the benefits of exercise – go for a bike ride, join a running group, or just go for a walk. If you can, do it first thing in the morning, so you don’t have a chance to avoid it. Your mind will be clear, you’ll feel good, and you’ll be set for a full productive day.

Your Environment

Lately I’ve been making an effort to keep my desk clean, and my room tidy. I put away all my test devices when I’m not using them, paperwork gets filed quickly, and the room is dusted and vacuumed once a week. This helps to avoid the mental drain that can come from being surrounded by clutter. I find it’s really nice to have a full desk to work on as well, rather than the little square that’s leftover if I leave stacks of books and papers around.

Some Character

Just because you don’t work in an office doesn’t mean you can’t spice up your space a little. Some people collect figurines, some people put up posters – me, I like to have a fish tank. I recently purchased a Fluval Edge tank, which is a neat little self contained aquarium. It looks great, and fits really nicely on the desk next to my iMac. Yes, I really am brave enough to put a box full of water next to my computer. Aside from giving me something interesting to look at every now and again, a tank full of fish makes for a great session of rubber duck debugging. If you don’t like what the first fish had to say, move on to the next one!

Regular Hours

I believe that keeping to a routine is a key factor in being a successful independent worker. Whilst I’m not super-strict about it, I generally work weekdays from 9.00am until 12.30pm, break for lunch for an hour, then continue working until about 5.30pm. At which point I stop. There are occasions where I’ll work longer hours, or work on the weekend, but this is the exception rather than the norm. This helps to give some normality to life, and also helps to avoid that “always at work” feeling that can creep in pretty quickly if you’re not careful.

Take Breaks

I’ve never liked the idea of sitting at my desk for many hours at a time, but it’s very easy to do, especially if you’re deep in some code. That’s why I installed Time Out, a free app on the Mac App Store. I have it setup so that every half hour I’m told to take a 10 second break – just enough to jump up from my chair, stretch my legs, and sit down again. Then, every hour I’m told to take a 5 minute break. I always try to make sure I walk around during this break, whether it’s to take the garbage out, check the mail, or just go outside for a moment. Rather than breaking my concentration, I’ve found on many occasions that these little breaks help me to have an “aha” moment, so I actually end up being more productive rather than less.

Work Isn’t Everything

This is a big one. Have you read The Top 5 Regrets People Have On Their Deathbeds? I’m particularly interested in point number 2 – every dying male patient in this article regretted working so hard. Every single one. There’s nothing wrong with working hard, but don’t let it come at the expense of your family and friends, because it’s very easy to do.

Know When It’s Time To Quit

Independent work isn’t for everybody. If you’re not happy, try and figure out whether it’s the work, or the work environment. If it’s the work environment, try some of the things above – or think about renting an office, or look into a co-sharing space. If it’s the work that makes you unhappy, you can always go back to a regular job – there’s no shame in trying something that didn’t work out.

Find What Works For You

Everyone is different, and on one can tell you the best way to live your life. However, I do hope that some of these things got you thinking. If you have any other suggestions I’d love to hear them!

Page 4 of 10«...23456...10...»