Xcode Treasures: Platform Specifics

The third update to the Xcode Treasures beta book went out yesterday, and this is a good one: it’s all about platform-specific features.

Table of contents for chapter 12

While the book sort of takes Swift + iOS as its default stance, I’ve used Mac examples where it makes more sense to do so, and I drop into Objective-C or C when I need to for language-specific reasons (like showing off certain debugging or profiling features). But this chapter is specifically about features in Xcode that only make sense for one platform, or that combine multiple platforms.

In part, this came from the fact that I knew from day one that I really wanted to do a section about writing command-line apps, since they’re short and useful and fun, and people don’t always realize that you even can write them with Xcode. There’s even a little bit of guidance for how to turn them into daemons or agents, and get them to the user’s computer via an Installer package, although Xcode is of no help whatsoever for doing install stuff, so I sort of have to point you in the right direction (pkgbuild and productbuild) and leave it at that.

There’s also a fair amount of tvOS stuff — on-demand resources and how you set those up in the project to have Apple host them for you, and building the layer stack images for app icons. For watchOS developers, Jeff Kelley suggested a useful and hard-to-find feature: setting up your own pairings of iPhone and watch simulators. Y’know, for those times you want to pair the newest iPhone with the oldest Apple Watch.

Xcode scheme selector watch targets customized

One particularly important part of the chapter is setting up a project to build for multiple platforms from the same codebase. I’d originally written it to add a tvOS app target to an iOS example from earlier in the book, but after editor Tammy Coron made a suggestion about reorganizing the sections of the chapter, I saw an opportunity to do this example as an iOS+Mac demo instead. Obviously, this was fresh on my mind after last week’s blogging, and will hopefully spur readers to take the leap into cross-platform projects now, instead of waiting a year for Apple’s well-at-least-it’s-not-Electron solution.

Svn commit message take that marzipan

True story: Tammy’s suggestion was actually about changing the flow to put watchOS before tvOS. As a consequence, this moved multi-platform between command-line (macOS) and watchOS, so making the multi-platform section be about Mac made for better flow out of the command-line material (since both are Mac) and into watchOS (since watchOS projects are by their nature multi-platform). It’s like it was meant to be, y’know? So I actually wrote the code and rewrote the section the night before the beta went out, and even tweaked a screenshot the next morning. Move fast and break stuff, I guess.

Two chapters left: Extending Xcode has been in the can for months, Testing still needs to get written. Not sure which one they’ll ship next, but we’re almost done now.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.