Xcode 8.2 simulator crash when save screen shot

Yeah, unfortunately, this is tripping over a bug in Foundation on OS X 10.11. You won't have the problem if you upgrade to macOS Sierra.

If you cannot upgrade to Sierra right now, you can still take screenshots from the commandline:

xcrun simctl io booted screenshot <path to output file>

This is mentioned in the Xcode 8.2 Release Notes

Simulator can crash when saving a screenshot when running on OS X El Capitan. (29182710) The crash does not occur on macOS Sierra.


Please find the below steps for getting the screenshot.

1) Go to Simulators -> Edit -> Copy Screen or you can use the shortcut (ctrl + cmd + c).
2) Open the Preview and go to File -> New from Clipboard or you can use the shortcut (cmd + n).
3) Now go to File -> Save or you can use the shortcut (cmd + s).

Or you can also refer the below GIF presentation.

GIF


So an easier workaround is this:

  1. Run app in simulator (obviously)

  2. In simulator go to Edit>Copy Screen

  3. Open Preview app
  4. Go back to simulator and save screenshot i.e. File>Save Screenshot

Done!

Not sure why this prevents the bug from occurring but it worked for me. It's faster than all the other methods described above.


The crash seems to occur due to a segmentation fault, or more specifically a general protection fault, while calling the saveScreenShot: selector. Why it happens can depend on several things, so it's hard to say whether a reinstall would help.

In any case, if the screenshot (⌘S) function in simulator causes the crash, there's hardly anything you can do about it. The best option you have is probably to file a bug report to Apple.

Update:

I just updated to the 8.2 GM, and low and behold, ⌘S crashes for me as well. Although I'm getting KERN_INVALID_ADDRESS instead of EXC_I386_GPFLT.

One workaround, for the time being, is copying the screen and pasting into Preview:

screenshot

Tags:

Ios

Xcode