UIKit for Mac
I’m exploring the new possibilities with Xcode 11 and macOS Catalina to create a Mac version of an iPad app using UIKit. Generally works as expected.
What’s the best way to customize the NSWindow
in an iOS app on macOS?
Go Beyond the Checkbox
https://developer.apple.com/documentation/uikit/creating_a_mac_version_of_your_ipad_app
You can use these same approaches to include a framework and code that are available only in macOS. For a framework, select macOS for the platform setting, and enclose the code with a #if targetEnvironment(UIKitForMac) statement.
As a starting point, I created a basic macOS framework (e.g.MacMan.framework
) to configure Mac specific behaviors.
Despite my best attempts, I run into errors:
- 'NSApp' is unavailable in UIKit for Mac
- 'NSWindow' is unavailable in UIKit for Mac
- Building for UIKit for Mac, but the linked framework 'MacMan.framework' is building for macOS. You may need to configure 'MacMan.framework' to build for UIKit for Mac or restrict the platforms for which this framework should be linked in the target editor.
The opposite seems true (easy to exclude code)
#if !targetEnvironment(UIKitForMac)
override var prefersHomeIndicatorAutoHidden: Bool {
return true
}
#endif
References:
https://www.highcaffeinecontent.com/blog/20190607-Beyond-the-Checkbox-with-Catalyst-and-AppKit