UISwitch initialization failure in SPM test for visionOS 2 & Xcode 16

In SPM package test running on visionOS 2, when creating a UISwitch we get a crash / error: Nil UISwitch visual element provided by <UISwitch: 0x102b15590; frame = (0 0; 0 0); layer = <CALayer: 0x6000004c1780>> (NSInternalInconsistencyException)

This issue only occurs on visionOS 2 in Xcode 16 with Swift Package Manager. It works fine when running on visionOS 1.2 in Xcode 16 with SPM, as well as on iOS 18 in Xcode 16 with SPM. Additionally, running the test on visionOS inside of a non-SPM package (Project test) is also fine.

What results you expected - The test should pass for UISwitch initialization on SPM for visionOS 2 on Xcode 16.

What results you actually saw - Test failure with error - Nil UISwitch visual element provided by <UISwitch: 0x102b15590; frame = (0 0; 0 0); layer = <CALayer: 0x6000004c1780>> (NSInternalInconsistencyException)

The version of Xcode you are using - Xcode 16

Feedback id - FB15254532

UISwitch initialization failure in SPM test for visionOS 2 &amp; Xcode 16
 
 
Q