If you want to compile code that runs only on macOS, you can do that by using the following, new compile time attribute:
#if targetEnvironment(UIKitForMac)
let toolbar = NSToolbar(identifier: \"MyToolbar\")
#endif
Obviously, to do it the other way around, you just inverse it:
#if !targetEnvironment(UIKitForMac)
import ARKit
#endif