Incorrect Behavior Displayed For visionOS App In Simulator

Hello, I’m working on a visionOS app. It‘s in early stages, but I’m already seeing my app’s UI behave incorrectly in the simulator, though it’s correctly displayed in Xcode’s SwiftUI Preview. My app’s UI size is displaying problems, and does not display its expected size it showed in the SwiftUI Preview.

This is how it looked like in SwiftUI Preview, and what I expected it to look like in the visionOS Simulator:

https://share.icloud.com/photos/080IVqZ3VeRuw5BgSFysLNasg

And this is how it looked like in the simulator:

https://share.icloud.com/photos/064Bod9e6_9wrb7tKsL24IEtQ

I did not expect this behavior. I’m running the latest Xcode 15 beta on a M1 MacBook Air. Any solutions? Thanks.

Hi @Christopher_Dumois , can you expand on what incorrect behavior you're seeing? Keep in mind that Preview shows only the UI of the single struct, not in the entire scope of the project. That means you may need to pull the window towards you with the bottom grab bar in the simulator to see it rendered at the same size.

Hi @sha921, the unexpected behavior I am seeing is related to the app's UI. It's too small when viewed in the simulator, which makes it difficult for a user of my app to see and interact with, keeping in mind Apple Vision Pro's unique interaction features, where a user uses their hands and eyes to interact with the app or game instead of a touch screen, mouse, trackpad, or controller. This results in a frustrating user experience for the user. I was expecting the size to be the same as the sim.

@Christopher_Dumois , did you try dragging it towards you? It looks like it's pretty far away in the simulator. Otherwise, you can set the default window size to be larger if you wanted by using .defaultSize (https://developer.apple.com/documentation/swiftui/scene/defaultsize(width:height:))

I solve the difference in both using preview code:

#Preview(windowStyle: .automatic, traits: .fixedLayout(width: 1280, height: 720, depth: 540)) {
    HomeScreen()
}

and for App screen size

@main
struct MyApp: App {
    var body: some Scene {
    WindowGroup {
        HomeScreen()
    }.windowStyle(.plain).defaultSize(width: 1280, height: 720, depth: 540)
}
Incorrect Behavior Displayed For visionOS App In Simulator
 
 
Q