Monday 3 October 2016

Symbolicate your iOS crash logs!

As a developer, how many times have you faced a situation where your game runs flawlessly on your development device, but after releasing it to a testing team or for approval to Apple’s App Store, the game crashes? 

If the game is built using Unity3d or any other game engine and you’re wondering where to look for the snag or from where to start, then read on. 

Digging through Unity3D code, third party or code for a custom plugin did not give you the desired results? Well, then you need to check the iOS crash logs.


So, our game was crashing at the launch screen. We received the crash logs from Apple as seen below:




The crash log above gives you all the basic information about the game and the type of exception along with the thread number details that are causing the crash.

Note:
You must be wondering where you could get the .crash file from. Here’s how:
 1) Sync your device with iTunes on your desktop. After syncing, look for
crash logs in Mac OS: ~/Library/Logs/CrashReporter/MobileDevice/<DEVICE_NAME>
2) Emailing from a device : Start by opening up the Settings app. Navigate to General -> About -> Diagnostics & Usage -> Diagnostic & Usage Data.
( Refer: https://developer.apple.com/library/ios/qa/qa1747/_index.html )

In the Log, we need to symbolicate it using .dSYM. As you see, Thread 0 is causing the crash:



Now, to Symbolicate we will be using the script provided by Apple, which you can find at:

Xcode7.3:
/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash

Xcode 6 to 7.2:
/Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/Current/Resources/symbolicatecrash

Before using this script we need to export the DEVERLOPER_DIR environment variable with a correct path to our Xcode

export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"


Now copy the .crash , .app and .dSYM files in the same directory (You can find .app and .dSYM file by renaming the exported IPA from organiser to .zip and extract).


Run this from the same directory:

/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash -v bluff.crash bluff.app.dSYM/



The output will be the symbolical call traces,        



Aha! now you know where the game was crashing.  [IOSKeychainPlugin requestDataForKey:] (IOSKeychainPlugin.mm:13)