Is it possible to save a screenshot of a preview in Xcode 14?

The the enhancements to Xcode Previews in Xcode 14 are very helpful.

I just had a situation where I wanted to take a screen capture of a preview of a view. Is there a built-in way to do that from Xcode, similar to taking a screen capture of the simulator screen?

I realize I can just use a system-level screen capture, but then I have to adjust the size of what I capture to the area of the view in the preview.

It would be great to just be able to have a button or shortcut and have the correct area captured.

Answered by Developer Tools Engineer in 735619022

Great ideas! Currently there is not a way to automatically save out an image / screencapture of a preview, but we know this is an often requested feature :)

Out of curiosity, how would you use the screenshot you export?

Accepted Answer

Great ideas! Currently there is not a way to automatically save out an image / screencapture of a preview, but we know this is an often requested feature :)

Out of curiosity, how would you use the screenshot you export?

In this case, I wanted to quickly send a screen shot of my work-in-progress to someone. As I mentioned, I could take a regular screen shot (and did), but having to crop the image is definitely a point of friction.

I could also imagine using screen shots to try out different layouts, taking a screenshot of each to show to others to compare.

I would imagine pretty much everything people use Simulator screenshots for would also be a use case for Xcode Preview screenshots, with the added advantage that Xcode Preview screenshots could be easily created subsets of the UI, not just the entire app.

Same Here. I want to be able to save screenshots from the preview for the PRs, cause the Screen is deep in the app and has several states that create a hassle to do screenshots of all states using the Simulator.

Is it possible to save a screenshot of a preview in Xcode 14?
 
 
Q