teamoh
teamoh

Reputation: 79

Xcode 14 Canvas preview wrong for connected device

I had this error already in Xcode 13 but it still persists in the current version. When I connect my iPhone XS to preview my SwiftUI app in the canvas, it shows the iPhone 14 Pro layout. However, when I check on Devices and Simulators, it's correctly recognised as iPhone XS.

So when I design my layout, I always have to switch between the iPhone XS simulator for designing, and my real device for testing.

Does anybody know a way to show the correct device in the canvas?

Upvotes: 1

Views: 1024

Answers (1)

Andreas Naoum
Andreas Naoum

Reputation: 41

I have the same issue and I found out that if you want to see the specific device type to canvas, you have to download the simulator for this device.

From the "Windows" tab, choose "Device and Simulators", and then Simulators. At the bottom left of the window, you can add new simulators.

Then choose your device type and download it.

Once you've added a new simulator, you can use PreviewDevice(rawValue: "Your Device Type").

For example:

I added a new iPhone 12 Simulator and use HomeScreen().previewDevice(PreviewDevice(rawValue: "iPhone 12"))

add simulator window

After that, I am able to see my screen as an iPhone 12.

Upvotes: 4

Related Questions