xcodeswiftui

Take Screenshot in SwiftUI Preview


I have some nice dummy data built out for my previews and don't want to have to replicate it on the simulator or my personal device (where I use the app myself with my own data)... How can I screenshot the preview window? Ideally would like to use it for App Store templates I've built in Figma.

Thanks enter image description here


Solution

  • You can change the preview device to your physical device and it will show the preview on your phone with the exact data that is in the Preview. Use the dropdown in the bottom left corner to select your phone. Now you can take screenshots on your physical device.

    Xcode 15 and above

    preview device dropdown in xcode 15

    Xcode 14 and below

    preview on device button on xcode 14