Facing the exact same problem on Xcode 13.3.1.
Fixed it by using UIDevice.current.userInterfaceIdiom in place of UI_USER_INTERFACE_IDIOM() as mentioned above.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: