Macs, Apple Silicon and You
Interesting day at Apple Park yesterday, as the first online-only WWDC kicked off with many exciting announcements across all of Apple's platforms.
There's a lot to digest, but for this post, which i'll be updating over the week, i'll be focusing on what IMHO was the most anticipated and most exciting announcement — the imminent switch for the Mac to ARM CPUs. Sorry, did i say "ARM"? I mean of course to "Apple Silicon" ;).
Apple might not have mentioned ARM by name, but it's clear (and confirmed by looking at the first Xcode 12 beta) that the new CPUs for the Mac will be AMR64 CPUs, based on the same architectures we've known from iPhone, iPad and Apple TV for a few years now. In fact, the developer hardware Apple will be providing to some lucky developers is using the same A12Z chip as is in the latest iPad Pro.
So, what do Macs running on ARM mean for Elements, Fire and the rest of our toolchain? Well, it means we have some work to do, but it's work that we're well prepared for.
Mac (just like iOS) applications have always supported whats called the Universal Binary (or Fat Binary) support, and ARM Macs will be using the same system. Essentially, a Mac application can be built as usual, but rather than just "x86_64" (64-bit Intel) code, the binary might contain additional so-called slices. In the past, apps might have had a "i386" slice for 32-bit Macs (which we never supported, since 32-bit had bene long deprecated by the time), and now they can have "arm64" slice, as well. When you run your app, macOS will pick the slice thats right for the actual hardware — ARM or Intel.
So what we need to do is to let you build ARM slices into your apps. And there's a few steps for that.
SDK Imports
The first, as always, is importing the new SDKs. We've done the hard word for you already, and new SDKs are up. To build an application against the macOS 11* SDK all you have to do right now is download Xcode 12, make it your active version in Preferences|Locations, and then build your Elements project. The first time you do it, you'll see this extra message:
You don't even have to download a new Elements install. Thanx to Automatic SDK Downloads, which we introduced in February, Elements will automatically find the new SDKs for you. (The same works for iOS 14, tvOS14, watchOS7 and macOS 10.16).
Wait, did you say macOS 10.16?
Yes. Apple is doing something weird this year. Officially, new new version of macOS Big Sur is versioned 11 (can I get a finally?). But for some reason they have provided two beta versions of Xcode 12. One supports ARM Mac development, supposedly requires macOS Big Sur to run (although it runs fine for me on Big Sur and Catalina so far), and that refers to the new macOS version SDK as "11.0".
There's also a second version of Xcode 12, which does not support ARM Mac development, officially runs on Catalina and — and here is where things become freaky — refers to the SDK for the new macOS as 10.16.
I don't know if this is a temporary thing for the beta and will be joined up later, or if Apple will keep the distinction (and wait for macOS 12 next year to unify the two). But right now, depending on which copy of Xcode 12 you have, you'll be building against macOS 11.0 or 10.16.
We're providing SDK imports for both, but only the 11.0 SDK has (yeas, it has them already) ARM slices in the import.
Build Chain
Ok, so your macOS 11.0 SDK files that Elements downloaded for you have ARM support. That's only half of the story though. There are a some changes we need to make to the overall toolchain to work with these, and enable you to actually select "arm64" as an architecture option.
These are changes we didn't want to ship before this was official, and that you won't get with an automatic update. So right now if you were to set the Architecture setting in your project, you'd just get
E: Unsupported architecture ('arm64') for macOS 11.0
| Supported architectures:
| - x86_64
But with literally just a single line of code change (that will of course be in Friday's build .2527) to let EBuild know that arm64 is, indeed, a valid architecture for the Mac, our project compiles fine and emits a valid Universal binary that runs (on x86_64 — since no-one outside Apple has any Mac hardware yet, we can't test the other slice, but our compiler is of course well-tested over the years against arm64 on iOS).
Oh, and of course this builds on Catalina. No need to install Big Sur (or as Apple actually called it in an email I got last night, Bug Sur) on your main development machine just yet...