2

For testing purposes, in the running app (not in a UI test), I'd like to take a true screenshot of the device with my app running, programmatically. I'm calling

let snapview = UIScreen.main.snapshotView(afterScreenUpdates: true) 

but the resulting image omits screen elements imposed by the system such as the status bar, the home "bar" at the bottom of a bezel-free device, etc. I'm guessing that this is deliberate for security reasons; I have the sense that Apple used to include those elements and no longer does so.

So am I just out of luck? Is there no way for my app to get an image of the screen as it actually appears?

4
  • i found some answers related this question, for example: stackoverflow.com/a/8509534/14531220 Commented Jan 20, 2021 at 20:23
  • @zeytin Yes, been there done that. The question remains: am I gathering from that and other question/answers the correct impression, that this simply cannot be done? Commented Jan 20, 2021 at 21:18
  • 2
    I'm pretty sure you're out of luck, unless you're willing to use private API (which I would assume you are since you say it's just for testing) to create a status bar view and home indicator view, add them to your window, and then take a snapshot view of the window/screen. Commented Jan 20, 2021 at 21:44
  • @matt it appears to me as you said "this simply cannot be done." Commented Jan 20, 2021 at 21:46

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.