Search code examples
iosswiftmacosmac-catalyst

On macOS, UIDevice.current.userInterfaceIdiom returning .iPadOS


On macOS 12.4, when calling UIDevice.current.userInterfaceIdiom from Mac Catalyst, it returns .iPadOS when the Scale Interface to Match iPad setting is enabled:

Destinations

However, if this setting is changed to "Optimize Interface for Mac," then UIDevice.current.userInterfaceIdiom works correctly on macOS.

Optimize for Mac

Is this the expected behavior?


Solution

  • This is the expected behavior from the documentation: https://developer.apple.com/documentation/apple-silicon/adapting-ios-code-to-run-in-the-macos-environment?preferredLanguage=occ

    On macOS, the UITraitCollection and UIDevice classes report the following iOS idiom types instead of UIUserInterfaceIdiom.mac