UIUserInterfaceIdiom Errors

Hello, I am getting following errors in Xcode console when running my app on the simulator with iPad Pro 13-inch (M4) 17.4:

CoreUI: _Bool CUIValidateIdiomSubtypes(NSInteger, NSUInteger *) passed a device subtype '2752' and idiom '2':pad that are not a matching pair, subtype is not valid with given idiom. Assuming subtype should be 0 instead.

This is the code:

import Foundation import SwiftUI

struct PrefersTabNavigationEnvironmentKey: EnvironmentKey { static var defaultValue: Bool = false }

extension EnvironmentValues { var prefersTabNavigation: Bool { get { self[PrefersTabNavigationEnvironmentKey.self] } set { self[PrefersTabNavigationEnvironmentKey.self] = newValue } } }

#if os(iOS) extension PrefersTabNavigationEnvironmentKey: UITraitBridgedEnvironmentKey { static func read(from traitCollection: UITraitCollection) -> Bool { return traitCollection.userInterfaceIdiom == .phone || traitCollection.userInterfaceIdiom == .pad || traitCollection.userInterfaceIdiom == .tv }

static func write(to mutableTraits: inout UIMutableTraits, value: Bool) {
    // do not write
}

} #endif

I am using this to decide what layout of the app to use – learned this from the Apple sample app Backyards Birds:

if prefersTabNavigation { AppTabView(selection: $selection) } else { NavigationSplitView { AppSideBar(selection: $selection) } detail: { AppDetailColumn(screen: selection) } }

Could you please help me find out what is wrong with the code?

@lukylab Could you verify if you're able to reproduce the error using the Backyards Birds sample project ?

UIUserInterfaceIdiom Errors
 
 
Q