Created
January 14, 2023 14:34
-
-
Save yannxou/4323ce24c20452a683f8ad2a28cebbf8 to your computer and use it in GitHub Desktop.
Swift: Check if app running as Catalyst with 'Optimized for mac' setting enabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credit: https://steipete.com/posts/forbidden-controls-in-catalyst-mac-idiom/ | |
extension UIDevice { | |
/// Checks if we run in Mac Catalyst Optimized For Mac Idiom | |
var isCatalystMacIdiom: Bool { | |
if #available(iOS 14, *) { | |
return UIDevice.current.userInterfaceIdiom == .mac | |
} else { | |
return false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternative (if native macOS is also supported):