SwiftUI previews don't work in multi-platform app

I created a native visionOS app which I am now trying to convert into a multi-platform app, so iOS is supported as well.

I also have Swift packages which differ from platform to platform, to handle platform-specific code.

My SwiftUI previews work fine if I just setup visionOS as the target. But as soon as I add iOS 17 (with a minimum deployment of 17), they stop working.

If I try to display them in the canvas, compilation fails and I get errors that my packages require iOS 17, but the device supports iOS 12. Which I never defined anywhere. This even happens if I set the preview to visionOS.

If I run the same setup on a real device or a simulator, everything works just fine. Only the previews are affected by this.

How do the preview device decide which minimum deployment version it should use, and how can I change this?!

Update: This only happens if the app has a package dependency for a Swift package that itself includes a RealityKitContent package as a sub-dependency. I defined to only include this package in visionOS builds, and also the packages themselves define the platform as .visionOS(.v1) If I remove this package completely from "Frameworks, Libraries, and Embedded Content" the previews work again. Re-adding the package results in this weird behavior that the preview canvas thinks it is building for iOS 12.

SwiftUI previews don't work in multi-platform app
 
 
Q