Export image from SwiftUI Live Preview in Xcode Canvas
Asked Answered
F

1

6

At the time of this writing there is no option in Xcode to export Live Preview in Canvas as PNG image (which would be useful for creating App Store Screenshots).

I'm not sure how this works under the hood but I guess regular simulators are also used in Xcode Canvas for Live Previews. Since it is possible to "Save Screen" from the simulator, I'm wondering is there a way to do the same from Live Previews in Xcode's Canvas?

Can I somehow access those "preview simulators" (ie. via simctl tool) or Xcode's render cache on disk, or is there any other "hacky" way to achieve this before Apple integrates this option in Xcode (which I believe is just a matter of time).

Furman answered 11/10, 2021 at 17:14 Comment(0)
I
0

I have tried to save a capture of the view hierarchy as an image to disk, but I was unable to save the file.

Another idea is to use an HTTP connection to upload the view hierarchy image to an HTTP server. I tested it, and it works.

Ics answered 24/10, 2023 at 16:47 Comment(1)
Capturing view hierarchy from the app code is a different topic, this one is about missing Xcode option to save screenshot from Live Preview like it is possible from the Simulator app.Furman

© 2022 - 2024 — McMap. All rights reserved.