Category Archives: Xcode

The book that started it all

When I was asked to write Beginning Xcode I initially said no. Mostly this was because of a fear of exposing myself to international criticism – I had enough trouble coping with the local kind, dealing with anxiety issues like imposter syndrome and the like without opening myself up to harsh reviews and the inevitable burning rage that meant my reply would probably be far form professional.

I thought about my decision for a couple of days and then changed my mind – decisive as always. I have a tendency to self-deprecate (after all it’s harder to be mocked for something if you’ve said it first), but I’ve still felt that for someone who wasn’t particularly academic I’ve done really well – mostly because I love what I do and that makes learning easier.

I don’t really remember where my interest in computers started, but I have early memories of my uncle having a ColecoVision back when I was 5 or 6 and that was my first introduction to computer gaming. From there I ended up getting a Spectrum and Commodore 64 (about 10 years after they came out – we were poor) and while the tapes were fun and all, I wanted to make these machines do the things I wanted them to do and for this I turned to books.

One book in particular sticks out in my mind; Sixty Programs for the ZX Spectrum. There were such variety in the applications, and there was no lengthy explanation for why you were doing something it just gave you pages of code and left you to it. My sister and I would sit for what seemed like hours typing in the code on the unforgiving rubber keyboard of the Spectrum 48k, typing feverishly to get to the point where we could press run and hope that each of the 200 or so lines were perfect; they never were.

Yes, the book is as memorable for its infuriating bugs as its brilliant code but that was all part of the charm. Back then there was no popping online to the publishers website for the errata updates, you had to figure things out for yourself – learning by necessity.

I’m writing this post because as I sit outside in the garden (making the most of the sun but struggling to read what I’m writing on the screen) I’m uploading zip files of images for the Swift 3 version of Beginning Xcode and got to reminiscing about how I got here and why. Even today – the era of digital everything, programming and development books have a huge part to play in helping the next generation of coders find their way. I hope the crippling neck pain writing these books has caused me goes on to help another person somewhere make their dreams come true.

So you started your iOS 8 project with a specific size class

When you move from Xcode 5 to version 6 for iOS development, one of the concepts that can be difficult to wrap your head around is Size Classes. Size Classes are great, they allow you to use a single storyboard for multiple form factors and screen orientations, but they can become very complicated as you add more and more class-specific settings and constraints.

[av_image src=’×400.png’ attachment=’2097′ attachment_size=’portfolio’ align=’right’ animation=’pop-up’ link=’lightbox’ target=” styling=” caption=’yes’ font_size=” appearance=”]
A basic project started in the wCompact hAny size class

One pitfall that’s easy for developers to make is to start laying out their app using a specific size class, for example an iPhone app may be started using wCompact hAny because the design area in the storyboard takes on a familiar landscape shape, which is less disorienting that the default wAny hAny layout you are presented with for all apps.

The challenge with this approach comes when you’ve set all of your constraints and have your layout working perfectly on a 4-inch iPhone, but when you rotate it or try it on a larger device, it all goes wrong and elements become unaligned, too large or small, and sometimes disappear altogether. The reason for this is that the constraints you set under wCompact hAny will often only be valid when those conditions are met. thankfully there is a straight forward way to get your constraints to be applied in different size classes.

Select a constraint from the Document Outline and then open up the Attributes Inspector. As you will see in the image below, you will have a tick against wC hAny, meaning this constraint is only valid in that layout, but the blank item above it (which should really be labelled wAny hAny) is not ticked. Click this to make the constraint apply across any layout.

Screen Shot 2015-03-01 at 10.02.27

HOW TO: Start a New Xcode Project From a Git Repo

I’m currently putting the finishing touches on the Swift edition of Beginning Xcode, when I thought it would be nice to take a break and do some blog writing instead. Specifically, I realised that Xcode doesn’t make it really clear how you go about turning a url for a Git repository, say into a new project without downloading it.

It’s actually super easy to do this, and save yourself the hassle of managing the download, extracting files etc.

1. Start by choosing a Git repo that you want to work with, I’m going to use the one from my SpriteKit particle effects tutorial,

2. Next, Open Xcode, and go to  Source Control > Check out





3. Enter the url of your Git repo and click Next








4. Finally, choose a location to create the project and click Check Out.

After a short while depending on the size of the project, Xcode will have your project set up, ready to go.