SwiftUI Canvas

Hi everyone, I think this is a simple issue. I got the following error message"

"PreviewDevice is ignored in a #Preview macro. Use the device picker at the bottom of the Canvas to change which device type is used for the preview. (from macro 'Preview')"

after this line:

".previewDevice(PreviewDevice(rawValue: "iPhone 17 Pro"))"

But in my Canvas I do not see the device picker.

Thank you.

Answered by darkpaw in 867751022

When you say you needed to "download iOS 26.1" do you mean via the "Add Platforms..." button?

Just want to be clear so that anyone else who happens upon this thread knows what the actual solution is.

Remember to mark an answer as correct so everyone knows there's a solution to the problem. Thanks!

Show us a screen grab of the bottom of the canvas. You should have something like this:

Thank you for replying! This is the image I have; notice that the selection 'Automatic - iPhone 17 Pro' is missing.

Have you got any platforms downloaded in Xcode > Settings... > Components?

Can you show us the #Preview macro you're using?

What version of Xcode are you on?

Here are the platforms:

Here are the #Preview macros (commented out for now because they don't seem to to anything at this point)

Not sure if this is the issue, but you don't have any Simulators listed in the "Other Installed Platforms" section.

Click the "Add Platforms..." button and add the iOS 26.1 Simulator, and see if the device picker appears.

If not, you might have to add a simulator in the Window > Devices & Simulators > Simulators tab.

Hopefully this fixes it.

Thank you so much, really appreciate it. The fix was as follows: download iOS 26.1 and then added to supported destinations iPhone and iPad. It works now.

Accepted Answer

When you say you needed to "download iOS 26.1" do you mean via the "Add Platforms..." button?

Just want to be clear so that anyone else who happens upon this thread knows what the actual solution is.

Remember to mark an answer as correct so everyone knows there's a solution to the problem. Thanks!

Yes, correct, via the 'Add the Platforms...' button and then the "Supported Destinations":

SwiftUI Canvas
 
 
Q