113

Are there any crash logs generated by iPhone Simulator?

the Simulator crashes a lot but not leaving any traces in Console... the crash log will be useful.

Raptor
  • 53,206
  • 45
  • 230
  • 366
  • 3
    I don't quite understand why you need the crash logs. When the app in the simulator crashes but before you stop the debugging, at the gdb prompt type "bt" for "backtrace" -- you'll get exactly what would appear in the crash log. (didn't realize there was question necromancy here, missed the post year) – Matthew Frederick Dec 09 '10 at 22:53
  • 4
    If the crash only occurred when you weren't attached by the debugger then you would need the logs. – Ian1971 Aug 01 '11 at 13:59
  • you're right. this make sense! – Raptor Aug 02 '11 at 00:19
  • You can also see the debug log (including output of lldb commands) in the "Report navigator" in Xcode (cmd-8). This is useful for seeing the debug output for previous runs too. If the debugger wasn't attached, then this won't work obviously. – Sebastien Martin Feb 24 '15 at 18:33
  • 2
    Debug log is not the same as Crash log, though both logs are useful to debug the problem. – Raptor Feb 25 '15 at 01:53

7 Answers7

177

The console will show the NSLog() output from an app running in the simulator. The crash logs are saved to file.

I have found some in my home directory under

~/Library/Logs/DiagnosticReports/

They have a file extension of .crash

Something I haven't yet figured out is how to get them to generate even if the debugger grabs the EXC_BAD_ACCESS signal.


Update

Currently, (OSX 10.11.6), the .crash logs in ~/Library/Logs/DiagnosticReports, are when the emulator itself crashes. Logs for an app crashing (but the emulator device is still running fine), are in:

~/Library/Logs/CoreSimulator

Per crash, there is a sub-folder with a unique id. Sort by date, so that your recent crash is the first sub-folder. Inside that, start by looking at stderr.log and system.log.

Also directly under CoreSimulator, see CoreSimulator.log and Simulator.log.

ToolmakerSteve
  • 18,547
  • 14
  • 94
  • 196
ohhorob
  • 11,695
  • 7
  • 41
  • 50
  • Any idea why these logs are written to file instead of showing up in the console? Thanks for the info, btw. – aqua Mar 13 '11 at 05:02
  • 11
    None of my crash reports in iPhone or iPad simulator show up under this directory, maybe this answer needs to be updated? – Justin Nov 24 '11 at 16:34
  • 3
    Perhaps it does need an update, but a down vote isn't a very polite way to encourage it. – ohhorob Nov 24 '11 at 17:32
  • @Justin This answer is still valid November '12 so I doubt the answer was incorrect (needed updating) a year ago. – Benjamin Dobell Nov 26 '12 at 05:15
  • from other SO question, there is a (seem-to-be) valid answer: http://stackoverflow.com/a/11228598/188331 – Raptor Dec 07 '12 at 01:56
  • 2
    I found the crash report in the mentioned directory, but there was only one report and it was not the most recent one (i.e., I kept trying a few things in the app and it kept crashing). The crashes were all the same, so it wasn't an issue, but I am wondering if this is generally the case? – Samik R Dec 08 '12 at 07:46
  • 15
    Both Justin and ohhorob are correct. You need to launch the app on the simulator WITHOUT Xcode and reproduce the crash to see the logs in `~/Library/Logs/DiagnosticReports/` – Dave Chambers Aug 11 '13 at 11:26
  • In my DiagnosticReports directory no any .crash files. – Shah Nilay Dec 22 '14 at 12:43
  • On OSX 10.11.6, the .crash logs in `~/Library/Logs/DiagnosticReports`, are when *the emulator itself crashes*. Logs for an app crashing (but the emulator is still running fine), I see in `~/Library/Logs/CoreSimulator`. – ToolmakerSteve Feb 16 '17 at 22:29
  • As @DaveChambers said, dbl-click the app in the Simulator, watch it crash, then go to `~/Library/Logs/DiagnosticReports/`, or, in the `Console` app open `DiagnosticReports`. I really needed this info - mid-2019 using latest Xcode/MacOS etc. – David H Jun 27 '19 at 13:32
  • I see logs for an app crashing (but the emulator is still running fine) inside `~/Library/Logs/DiagnosticReports/` not `~/Library/Logs/CoreSimulator/`. – shoe May 29 '21 at 18:37
22

I am pretty sure that you can see this in the OS X Console app located in Utilities. If I'm wrong though, be sure to vote me the heck down so I delete this.


UPDATE:

Specifically (as of OSX 10.11.6),

When an app crashes on emulator, a subfolder (with a unique id) is added to:

~/Library/Logs/CoreSimulator

Within that, start by examining stderr.log and system.log.

When the emulator itself crashes, a subfolder is added to:

~/Library/Logs/DiagnosticReports

Don't confuse this path with

/Library/Logs

(lacking ~ at start), which has different reports about your mac.

ToolmakerSteve
  • 18,547
  • 14
  • 94
  • 196
bpapa
  • 21,409
  • 25
  • 99
  • 147
  • Yep. More info here http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/130-Debugging_Applications/debugging_applications.html – Brandon Bodnar Dec 08 '09 at 04:33
  • seems that it only applies to iPhone devices, instead of simulator. Correct me if I am wrong. – Raptor Dec 09 '09 at 07:50
  • 8
    The Console can be opened from the simulator by pressing Cmd-/ or using the Debug/Open System Log... menu option. – lambmj Jun 26 '14 at 16:10
5

Here’s something that worked for me in a special case... My app was crashing with SIGKILL as it terminated. I would see the exception in main.m for a few seconds, and then the app would finish terminating – thus, no chance to get the back trace.

I did a lot of searching on “where does simulator store its crash logs” and never managed to find an answer. However, the following trick came in quite handy and I was able to grab the crash log on the fly:

Basically, open /Applications/Utilities/CrashReporterPrefs.app and change the setting to “Developer”. This will cause CrashReporter to display a popup with the crash log after your app crashes.

I found this in the “Viewing iOS Simulator Console and Crash Logs” section in this doc from Apple: http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/ios_development_workflow/125-Using_iOS_Simulator/ios_simulator_application.html

dana_a
  • 95
  • 1
  • 2
  • By the way, the original problem with SIGKILL that I was researching turned out to be a non-issue: http://stackoverflow.com/questions/7901262/xcode-debugger-stops-with-sigkill-on-stop-button – dana_a Nov 03 '11 at 19:44
  • I should point out that there was no CrashReporterPrefs app in Application/Utilities, however I searched for it and was able to find the app elsewhere. – Justin Nov 24 '11 at 16:37
  • @Justin where did you find it? – Ohad Schneider Jan 12 '15 at 14:31
  • 1
    Note that the tool referred to above is downloadable from Xcode in a bundle called "Additional Tools for Xcode" https://developer.apple.com/download/more/?=additional%20tools%20for%20xcode – markshiz Sep 14 '18 at 20:31
2

The crash crash logs will appear under ~/Library/Logs/CrashReporter.

  • If the iPhone simulator program crashes (not the iPhone app running within the simulator), then there will be an entry for iPhoneSimulator.
  • If the iPhone App within the simulator crashes, the crash log will appear with the display name of the app.

When Xcode gets crash logs from a connected device, it stores them in sub-folders of ~/Library/Logs/CrashReporter/MobileDevice

Walt Sellers
  • 3,806
  • 30
  • 35
  • This is over a year later but I see the "app within simulator" crashes at ~/Library/Logs/DiagnosticReports ... and it looks like: MobileSafari_2013-03-21-155844_My-MacBook-Pro.crash – Rob Mar 21 '13 at 23:08
1

This is much more reliable. In only a few steps I was able to find the source line number & method name:

  1. cd to the dir having the .app & .dSYM files
  2. run /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin MyApp.app/MyApp
  3. set print asm-demangle on
  4. set print symbol-filename on
  5. p/a 0×00015c64 -> address got by opening the crash log in “Console” app or just double clicking the the .crash file.
futureelite7
  • 11,462
  • 10
  • 53
  • 87
Gamma-Point
  • 1,514
  • 13
  • 14
  • 3
    I don't quite understand why you need the crash logs. When the app in the simulator crashes but before you stop the debugging, at the gdb prompt type "bt" for "backtrace" -- you'll get exactly what would appear in the crash log. – Matthew Frederick Dec 09 '10 at 22:55
  • This method works great for the crash logs from client phones. – Gamma-Point Dec 11 '11 at 01:32
0

For me, it was an expression that I had added to the debugger watch window. When a breakpoint was getting hit, the bad expression was causing XCode to segfault.

pTymN
  • 53
  • 4
0

You may also want to take a look at this related answer: https://stackoverflow.com/a/14984297/679240

None of the answers above worked on the "Big Sur" OS version. The only way to find the log was through the "Console" app (Application/Utilities/Console)

Haroldo_OK
  • 6,612
  • 3
  • 43
  • 80