Category Archives: iPhone

Playing a Book

I’ve been thinking a lot about what books are for. Specifically, non-fiction books, and more specifically programming books. I’ve finally figured out how to describe what I’ve been thinking: You don’t read a programming book, you play one.

I mean play, like playing a game. In a game, you progress through levels by learning and applying skills. At the end of the level, you play against a boss that you have to beat to progress.

In books, you progress through chapters. But, there is nothing that stops you from just reading and reading and reading and well, not learning or applying anything. At the end of a chapter, you can just turn the page and keep going.

Over on App-o-Mat, an iOS content site I maintain, I’ve been working off and on a companion to the The Swift Programming Language book by Apple. I started the companion on with a short section on how to read the book, where I said you should it read it side-by-side with an Xcode Playground page open. That you should not copy any code into it, but type code as you learn it. Get used to typing code.

Then, for each chapter, I offer some simple exercises that let you know that you understood the chapter.

I now realize that I was turning chapters into levels with bosses, which make The Swift Programming Language a book you can play.

WWDC 2020 Wishlist – Xcode / Swift

Yesterday I posted my watchOS WWDC wishlist, which is driven by what I am seeing in building Sprint-o-Mat.

I recently started working with Typescript and VSCode on an open-source project that needs a Swift and TypeScript version of the same functionality. I wrote a Swift version, and then did a very faithful (almost line-by-line) port to Typescript, which I did not know at all before starting. I never used VSCode (or Atom) before starting.

Microsoft makes excellent developer tools.

My project is admittedly very small, but luckily I can see how it works with with a large project because a minimal React site with Typescript has 48k files of dependencies. VSCode has nearly instantaneous code-completion and real-time error reporting. A minimal app in Xcode isn’t nearly as fast or reliable.

The combination of VSCode and Typescript makes Xcode and Swift look a decade behind. It’s comparable to Apple’s lead in chip design and the advantage that gives to its products — that’s the kind of lead Microsoft has in developer tools. Luckily for Apple, that advantage mainly flows to in-browser and server-side development, where Swift has effectively no usage.

Xcode / Swift Wishlist

  1. Make Xcode reliable and fast
  2. Make Swift compilation reliable and fast
  3. Make Swift type inference flow knowledge about values into conditionals. Here’s a simple example:

    let x = (anOptional != nil) ? funcExpectingNonNil(anOptional) : fallback

    We (and Typescript) know that anOptional is not nil in the call to funcExpectingNonNil, but Swift does not.

WWDC 2020 Wishlist – watchOS

Like previous years, my wishlist is highly influenced by what I’m working on and is not a prediction — just stuff I have needed in the past year.

I Just released a new watchOS app, Sprint-o-Mat that helps me in outdoor running workouts. I had actually started it before WWDC 2019, but completely started over to do it as an independent watch app on SwiftUI.

Here’s what I’d like from watchOS

Allow the user to control location privacy in the watch’s settings app
You can already control HealthKit authorizations on the watch, but changing location authorization makes you use the iPhone. This is impossible to link to, and very hard to explain.

Make some SwiftUI equivalent to WKInterfaceTimer
This view is what makes showing a timer easy and performant. You can update it with elapsed time at a low frequency, but it updates its view in between so that it looks like a running timer.

Unfortunately, you can’t even host WKInterfaceTimer in a SwiftUI View (via interop) because it doesn’t have a default init (and can only be constructed via a Storyboard)

Allow workout apps to keep showing on the display when a workout is running
When you run the built-in Workouts app, the display stays on and shows the UI of the app. For 3rd party workout apps, when you lower your wrist, the display shows the time and a frozen UI under a blurred overlay.

This means that 3rd party workout apps require the pre-always-on wrist movements if you want to see their updated UI.

Add the APIs that the Workouts app uses to send data to the Activity app
The built-in Workouts app appears to have private APIs (or private metadata) that the Activity app uses to enhance the workout display (e.g. custom icons, per-segment data). I’d like to see those, and even new ones, publicly available to any workout app.

Make some canonical way to base font-sizes on display size
There isn’t a good way that I can see to make a single View for 38mm and 44mm watches that look good without hardcoding or hacks.

There are a lot of other issues that I ran into, but the general idea of an independent watch app coupled with SwiftUI and the simplified app architecture more than makes up for it. If Apple just keeps moving this forward in big steps, I’ll be pretty happy.

WWDC 2019 Wishlist Results

Parameters in SiriKit custom intents & Fine-grained Shortcut integration (apps provide blocks): Parameters are definitely in and I believe (from the SOTU demos) that the Shortcuts app can directly call into intents with parameters, thus enabling more fine-grained interactions. This is great news, and even if you don’t think Siri as a voice-assistant would be useful for your app, you should want this for Shortcuts integration.

On-device transfer learning in CoreML: This is also in and unlocks all kind of on-device ML applications. There is also a new category of “easy” ML integration (voice/sound analysis) along with a ton of other improvements. CreateML is now a Mac app instead of being integrated into Playgrounds.

HKLiveWorkoutBuilder (from watchOS) in iOS: I don’t see any mention of HealthKit or workouts at all in the release notes, so no luck here.

Web->AppStore->App ad attribution (w/o user tracking): Even though this was not announced, I have some hope that this could happen. The WebKit announcement of an privacy preserving ad click tracking mechanism is evidence that this problem is on their radar.

The App Store story is even worse, because there is no official way to pass some kind of data through your App Store URL that the App gets on first start. The normal attribution mechanism, IDFA, is not available to websites (only apps), so the only way to do a website-ad -> AppStore -> App attribution is for the web site and App to “fingerprint” the user somehow. One simple way is a correlation with time and an IP address, but that isn’t perfect. Unfortunately, many apps (and 3rd party ad trackers) do not stop there.

The last few years have been a cat-and-mouse game between Ad Tech firms finding loopholes in iOS (e.g. shared Pasteboards) and Apple closing them. It would be much better if Apple provided a privacy preserving mechanism and then explicitly forbade anything else in the developer agreement.

Multi-select image picker: No luck this year.

WWDC 2019 Wishlist

Today I tweeted

Here’s a quick elaboration

Parameters in SiriKit custom intents: The custom intents that were introduced last year do not support recognition-time parameters. All of the parameters of the intent must be baked into the intent. SiriKit calls this “resolving parameters” and the built-in intents all support this, but custom ones do not.

On-device transfer learning in CoreML: Transfer learning allows you to build a new model from an existing one by providing more examples. CoreML added that last year, but you still need to train and build the new model off-device. I’d like a way to build new models this way on-device from device gathered examples (which would preserve privacy).

HKLiveWorkoutBuilder (from watchOS) in iOS: This class is only available for watch workout apps, but a simpler version would be nice for iOS workout apps. It obviously can’t gather heart rate, but it could automatically build the route and perhaps use a less sophisticated algorithm for guessing calories burned.

Web->AppStore->App ad attribution (w/o user tracking): The WebKit team just announced a privacy preserving ad attribution system for websites. I want the same thing to work for an ad for an app that appears on the web, App Store, or in another App. No need to attribute to a user — just the ad source is sufficient.

Fine-grained Shortcut integration (apps provide blocks): The Workflow team integrated the x-callback-urls of a bunch of popular apps into blocks — and Shortcuts still has them, but as far as I know, there’s no API for apps to provide small bits of functionality for Shortcuts to use as a building block. Even with the ones they have, the app comes up, does a bunch of stuff and then returns. A more streamlined experience would be nice.

Multi-select image picker: The current UIImagePickerViewController doesn’t support multi-select of photos. If you want to do this, you can build your own VC, but then you need to ask the user permission to their entire photo library in order to show them the photos. Since iOS 11, you have been able to bring up a picker without permission since it runs out-of-process and doesn’t give your app any access to the photos–just the one the user picked.


I will be speaking about my experience with RxSwift at SwiftFest 2019 in Boston on July 29-30. Last year, I spoke there about how to sketch iOS UIs in Playgrounds — unfortunately the talks are not available online, but I’ll be putting together a video shortly that covers the material I spoke about.

I highly recommend this conference — it’s two-track and has about 300 attendees. I went to talks every chance I got and learned a ton. It will also be a good time to discuss the ramifications of WWDC as we’ll all have add a couple of months to absorb iOS 13.

If you are going to be there, contact me here or on twitter.

App-o-Mat updates

I started App-o-Mat as an iOS tutorial site back when I was consulting. It mostly had cordova screencasts.  I’m going to be doing more writing about iOS there (native and possibly cordova-based).

You can subscribe to the mailing list there if you want to get updates. If you have requests for topics to write about, let me know.

Here are the latest posts:

How do I pass values from a VC back to the VC that presented it?

Ok, so you have a view controller that brings up another view controller. Let’s call the first one FirstVC and the second one SecondVC. FirstVC either presents SecondVC or there is some segue that it uses to bring it up.

How do you keep Storyboards from causing merge problems later?

There’s this myth in the iOS community that “professional” iOS developers never use Interface Builder. It’s meant to imply that coding your interfaces is always better, and if you don’t do it, you are somehow less of a programmer. The myth perpetuates the idea that IB is a crutch, a toy, something that only newbies use.

I call BS.

How do you pass values to a VC in a segue?

A theme I see a lot on StackOverflow is a developer makes a View Controller that collects some information from a user and wants to use it on a VC that they bring up in a segue.


Introducing 3D-o-Mat

3D-o-Mat is a simple app that creates the type of 3D photos that you view with red/cyan glasses.

I have been writing apps that do this for a while. It was one of the first things I wrote with DotImage back when I joined Atalasoft in 2006 and ported their image processing commands to WPF. Then, I wrote a simple version for iOS that I showed to middle-schoolers when I was a volunteer for DIGITS.

I was recently invited to speak at a Smith College Python programming summer program for HS girls and I decided to make this app more real.

PS: here’s a tweet sized version of the app in Python that I shared with the class the last time I spoke:

This gist shows a better way to do it that preserves the color in the original photos.

GamePlayKit Rule Systems on Smashing

I wrote a 2-part series on GamePlayKit’s Rule Systems framework for Smashing Magazine.

Part 1 is the basic idea and shows how to replace conditional logic that might be strewn around a project into a GamePlayKit rule-system.

In Part 2, I show the support for fuzzy logic rule-systems (logic values ranging from 0.0 to 1.0 instead of strictly true and false). It covers a little more of the features of rule-systems and how to implement NOT, OR, and AND for fuzzy values.

Both articles are supported by Swift Playgrounds in GitHub so that you can play with the concept and try different rules.