Getting started with Apple’s iOS samples

It all started with me seeing an original Mac in a computer store in West Lafayette, Indiana when I was going to Purdue University in the 80s. Playing with MacPaint was magical, and when I finally got a Mac Plus a year later, I spent the better part of three days in ResEdit, looking through everything to figure out how it was put together. This was followed shortly by a purchase of Lightspeed C and a volume or two of Inside Macintosh, and a picture of me working through a book on 68000 assembly language is below. Good times, and I still bleed six colors.

So, we come to 2018 and this iMac I’m sitting in front of, and I’m still at it. iOS is definitely where Apple is putting its hardware and software efforts these days, so let’s start going through the sample code for iOS. While Apple has an excellent new Documentation page which is great for getting an idea of all the frameworks, services, and tools at your disposal for application development, I’m going to focus on the iOS sample applications in this series of posts.

To get started

You’ll get a list of 233 samples (at the time of this writing), and sorting by date, we see they start in mid-2009, almost 9 years ago:

Screen Shot 2018-01-18 at 7.13.02 AM

There’s a lot to go through, so let’s get started!


WWDC 2017

WWDC 2017 runs 5-9 June 2017, at which (among many other things) the next versions of iOS and macOS are expected to be announced with the end-user releases coming 3 months later in September. What this also means is the MacBook I’m writing this on – one of the oldest machines which can run macOS Sierra – will likely *not* be able to run the next versions of macOS and Xcode. <sigh> I might also want to reconsider getting an iPhone SE, although the fact Michael Tsai uses one is a compelling factor. However, I probably have to bite the bullet and either get an iMac or a MacBook Pro in October or so… and a reasonably modern iPad. Ugh.

Actually, I should be able to run Xcode 9, so maybe I can push off a new Mac purchase to 2018.

UPDATE: well, it looks like macOS High Sierra will run on the MacBook just fine. <phew> Of course, I’m really lusting after an iMac Pro now…

Starting a Meetup

After attending the Orlando iOS Developer Group’s Meetup last week, I’m considering starting something similar for the Space Coast. I have no idea how many other Apple developers there are in this area, but I’d like to find out and see if we can get a community going.

I’m thinking of naming the group Space Coast iDevelopers

For interests (limit 15), I have

  • Mac
  • iPhone
  • Apple
  • Objective-C
  • iPad
  • iOS
  • iMac
  • MacBook
  • Xcode
  • Swift Language
  • tvOS
  • watchOS
  • Server Side Swift
  • macOS

For a description, I was going to use:

Interested in building apps for the iPhone, iPad, Mac, Apple TV, or Apple Watch? Interested in Swift, Objective-C, and Xcode? From newbies to experts, all skill levels are welcome.

The one thing I need to figure out to really take a crack at this is where to hold the meetings. I also need to line up sponsorships, but I’m fine buying pizza and soda for the first few meetings until it takes off.

The Suntree-Viera Public Library has a 10-15 person conference room I could probably use to get the group started, but I just realized I should also have a 1080p projector. That’ll run about $50-100, but I can list it as a business expense, so it might be worth it. I could get a 32″ HD TV instead for a little more and schlep that around instead: might actually be a better option.

Blacklisting cache folders

Good tip in this article about build times on 12-core Mac Pros for Swift projects:

Disable Spotlight indexing for build cache folders. I saw 10% improvement after blacklisting derived data, cache and related folders (“~/Library/Developer” and “~/Library/Caches”) from Spotlight indexing.

Update: actually, from recent comments on the article, it looks like ~/Library/Developer/Xcode/DerivedData is a better candidate than ~/Library/Developer

Refactoring Swift code in Xcode 8

It isn’t possible at present:

Can't refactor Swift code

Yes, there are tools like Refactorator I can add to Xcode to provide this, but this goes against my minimalist/cheap approach, and frankly, unless it’s something on the order of JetBrains’ ReSharper, why bother? Well, there *is* JetBrains’ AppCode, and maybe I’ll check it out when I’m past the inflection point on the Swift learning curve, but $200 more into what is at present a hobby is hard to justify.

Ugh, just ran into an ugly bug in my code, and I can’t find a way to have the Swift compiler warn me about it. My class has a property named progressView

 var progressView: UIProgressView!

– and I inadvertently aliased it with a local constant in a function –

let progressView = UIProgressView(progressViewStyle: .default)

– with the net result that I crashed in KVO code because the progressView property was nil.

Back in Mac

Well, I’m back on OS X macOS and iOS, and pretty happy about it. While I’m very lucky in that I get to work from home and I have a pretty good boss and I like the people I work with, I still have an itch to go solo.

Before we moved back to Florida, I sold my underpowered MacBook Air, got a Surface 3, and toyed with the idea of getting an MCSD and building UWP apps, but honestly, nobody seems to be doing it. Look through job listings for UWP or WPF work and you’ll see what I mean. Crickets.

So, I decided to go back to the Mac, my first love. Admittedly, there aren’t that many macOS jobs either, but there are lots of iOS jobs, and while I don’t really want to work for someone else again, that tells me there’s at least a market there if I decide to build something.

I decided to run light (without overbyte? 😉), though. I wanted to get the cheapest minimal system I could get away with the learn Swift and iOS development, and after looking hard at Mac minis and iMacs and MacBook Pros, I settled on late-model MacBooks, specifically the white polycarbonate so-called CrackBooks (because of all the cracks which developed in their cases). I found one in beautiful condition for $330 on eBay (2.4 GHz Core 2 Duo with 4 GB of RAM), immediately replaced the slow 5400 RPM hard drive with a 1 TB SSHD I happened to have available, and bumped the RAM to 16 GB ($130 at OWC). I also bought a snap-on case in orange (shades of the original clamshell iBook) for $10 and a small laptop bag for $10.

Before adding the RAM, Xcode was struggling with simple playgrounds, but now the RAM is maxed out, Xcode and the simulator are working fine. I was worried that with only two cores, the simulator would be crippled, but so far, it’s working fine. So, I’m cranking away at learning Swift and UIKit (more on that in the next post) for under $500, and I’m a happy man. It’s good to be back…