IPhone 模拟器生成的崩溃日志?

有没有 iPhone 模拟器生成的崩溃日志?

模拟器经常崩溃,但不会在控制台留下任何痕迹,崩溃记录会很有用。

52981 次浏览

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.

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.

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.

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

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

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.

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)