Can't archive Mac app with saveMachineStateTo

For some reason when I try to archive an app, which is using saveMachineStateTo function, it fails with this error:

Value of type 'VZVirtualMachine' has no member 'saveMachineStateTo'

It works fine when running as debug from Xcode. Also fails if I change run destination to release. I have project set to macOS 14. What can cause this?

Oh, wow, that’s tricky. In the <Virtualization/VZVirtualMachine.h> header the save and restore methods are wrapped in:

#if defined(__arm64__)

…

#endif

That means they’re not available on Intel. I’m still using an Intel machine, so I see this all the time. You must be using an Apple silicon machine, so you only see it when you create a release build, which builds the Intel architecture.

How to proceed depends on your deployment goal:

  • If your app only works on Apple silicon, remove the Intel architecture from your release build.

  • If virtualisation is only part of your app’s feature set, and so you want to support the rest of your app on Intel, wrap your virtualisation functionality in a conditional:

#if arch(arm64)

…

#endif

This is the Swift equivalent to the Objective-C in the earlier snippet.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Can't archive Mac app with saveMachineStateTo
 
 
Q