Recently we have faced an interesting issue with missing dSYMs... which was not an issue in fact but hindered automation for some Crashlytics users.
Everything started with a user reporting that in the build log everything seems to be fine but the dSYM file was not uploaded to Crashlytics. At first we thought that something went wrong with the step so we asked for the build log, but we didn’t find anything related to it, so we also checked the version number and UUID on Crashlytics and tried to upload the generated dSYMs manually, but we didn’t succeed.
Finally in the documentation of Fabric we found some useful articles about missing dSYMs. One says that “There can be certain situations however, when dSYM uploads fail because of unique project configurations or if you’re using Bitcode in your app”, so we checked again the build log and we found these two lines:
- UploadBitcode: yes
- CompileBitcode: yes
The issue is found, but how do we fix it?
What is Bitcode? What does it do?
Bitcode appeared first when Apple released Xcode 7 and it is an intermediate representation of a compiled program (part of app thinning) and it will allow Apple to re-optimize your app binary in the future without the need to submit a new version of your app to store. (For more information check this page.)
Let's get back to the Fabric article, which also says that "For Bitcode enabled builds that have been released to the iTunes store or submitted to TestFlight, Apple generates new dSYMs so we have to download the regenerated dSYMs from Xcode and then upload them to Crashlytics".
Yeah, this will work, but we wanted all of these things works automatically, so what's next?
Solve it with Fastlane!
Fastlane offers a solution with which you can download all available dSYM files from iTunes Connect and upload them to the crash reporting service (supported services are Crashlytics, Sentry, HockeyApp).
Note: The guide to setup the download_dsyms tool can be found here, take special care of the release versions.
Just define a lane in your Fastfile:
... and add a Fastlane step which runs your refresh_dsyms lane to a new workflow and set up a scheduled build to this new workflow. The schedule should be set to a time that is surely hours after you finish developing this app. This way if you deploy to iTunes Connect during the day, your build scheduled to the night will download the appropriate dSYMs and upload it to Crashlytics.
Note: The scheduled build will run automatically at the time(s) set, regardless of whether you've released a new version to iTunes Connect or not.