Debug information "DWARF" and crash logs - ios

I am trying to map my understanding of "DWARF" vs "DWARF with dSYM file" debugging info formats to what I see in the crash information for different iOS build configurations.
I was trying to fix a problem, where crashes on the build with debug configuration were not symbolicated by default. These were my build settings before the problem was fixed -
Strip Linked Product - Debug - No, Release- Yes
Strip Debug Symbols during Copy - Debug - No, Release - Yes
Debug Information Format - Debug - DWARF, Release - DWARF with dSYM file
What got it to work was setting the Debug information format to "DWARF with dSYM File" for debug configuration as well.
My questions is - why do I need to to set the format to "DWARF with dSYM File" if I am specifying that the product should not be stripped of its symbols into a dSYM file (in the strip linked product setting)?
My (probably incorrect) understanding was that if I set it to DWARF, then all the debug information would be inside the app binary and I do not need a separate dSym file for symbolication? Please help me with a better understanding of this.

On Apple's platforms, DWARF is never baked into the executable (except for unwind info). Enabling DWARF debug info just means that the .o files contain DWARF-formatted debugging info. The linker doesn't bring that into the executable, though.
If you request a dSYM file, a separate build step uses dsymutil to collect the debugging info from the .o files into a dSYM bundle or file.
Debuggers can use a map in the executable to look up the debug info in the .o files when needed, assuming you're debugging on the build machine. That's why you don't typically need a dSYM file for a Debug build. Symbolication doesn't have the executable, just a UUID for it. It could find the dSYM using the UUID, but it doesn't have the information to find the .o files.
See this answer by an Apple developer involved in implementing this stuff. Also, this older wiki article he wrote.

Related

Xcode not generating all required dSYMs even though Build Settings have Debug Information Format = Dwarf with dSYM

Xcode is generating one dsym, which has the name of my app as the filename (e.g. MyApp.app.dSYM), but it's not generating the other dsyms with the UUIDs that Firebase is constantly telling me that I'm missing. (e.g. 92248A4B-6CA2-3B54-9787-C007E25C018F.dSYM)
I've followed the instructions, but something is still wrong. This was working when we were using Fabric, but since we updated to use Firebase directly, nothing is really working properly anymore.
I've followed the instructions on how to change the Build Settings to make sure the dSYMs get generated, but my Build Settings were already updated like that when I following the migration instructions from Fabric to Firebase. Here is a screenshot of my Build Settings:
Here is a screenshot of my Run Script Build Phase:
In the Archive Build Log, the only reference to generating dSYMs is for the one MyApp.app.dSYM that I get, but I need the others generated too.
GenerateDSYMFile
/Users/kenny/Library/Developer/Xcode/DerivedData/MyApp-dttbmiamkojuotbcyjgzerxhcqun/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/MyApp.app.dSYM
/Users/kenny/Library/Developer/Xcode/DerivedData/MyApp-dttbmiamkojuotbcyjgzerxhcqun/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/MyApp
(in target 'MyApp' from project 'MyApp')
cd /Users/kenny/inaday2/svn-MyApp/trunk/apps/iOS/MyApp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil
/Users/kenny/Library/Developer/Xcode/DerivedData/MyApp-dttbmiamkojuotbcyjgzerxhcqun/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/MyApp
-o /Users/kenny/Library/Developer/Xcode/DerivedData/MyApp-dttbmiamkojuotbcyjgzerxhcqun/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/MyApp.app.dSYM
Settings look okay, attaching the script I am using and process. Hope these info helps.
To have all the dsyms you need to first upload the build to Testflight and then from Tesflight, you need to download the final processed dSYM.zip.
A folder appDsyms.zip will be downloaded, once this is decompressed, you will see list of dSYM's
Post that use below script to upload the same to crashlytics.
So there are few changes done in Firebase Crashyltics the way dSYM mapped to the build we upload.
Initially, there was a manual option as well to upload but now that's abandoned and the only way by running the script from your terminal.
Pods/FirebaseCrashlytics/upload-symbols -gsp YOUR_PLIST_FULL_PATH -p ios ~/PATH_TO_DSYM_ZIP_OR_FOLDER
**Example[Below is my working script to upload dSYM to crashlytics]:**
Pods/FirebaseCrashlytics/upload-symbols -gsp MY_PRROJECT_NAME/Support/Firebase/Prod/GoogleService-Info.plist -p ios ~/Downloads/appDsyms

How to address this warning generated by crashlytics / fabric?

Here is what I know/do:
I am importing Fabric via a pod.
The build script for Fabric is the last one
It is set to generate a dsysm
DEBUG_INFORMATION_FORMAT should be set to dwarf-with-dsym for all configurations.
This could also be a timing issue, make sure the Fabric run script build phase is the last build phase and no other scripts have moved the dSYM from the location Xcode generated it. Unable to process myapp.app.dSYM at path /Users/no-one/Library/Developer/Xcode/DerivedData/myapp-ahatoktzxteqbcaohqnktdtfczxr/Build/Products/Debug-appletvos/myapp.app.dSYM
Make sure your project build settings are generating a dSYM file.
Go into your target's Build Settings and then type in DEBUG_INFORMATION_FORMAT into the Search Bar that appears in the top right.
It looks like this:
And you can choose "Dwarf With Dsym" from the pop-up menu.

Debug warning Xcode - dwarf-with-dsym?

I get this warning upon compilation:
DEBUG_INFORMATION_FORMAT should be set to dwarf-with-dsym for all configurations. This could also be a timing issue, make sure the Fabric run script build phase is the last build phase and no other scripts have moved the dSYM from the location Xcode generated it. Unable to process FieldSense.app.dSYM at path /Users/dnb/Library/Developer/Xcode/DerivedData/myApp-ggomikgtclrabvaoqmbwhjyudhxy/Build/Products/Debug-iphonesimulator/myApp.app.dSYM
How to solve?
To solve this issue:
Go to your project settings
Select your target
Go to Build settings
Scroll down to Debug Information Format (make sure to choose All settings)
Set the values to DWARF with dSYM File

dSYM files for release builds

Do .dSYM resources contain any other information except DWARF information? I have created a release build of an app. Now if I run dwarfdump on it, it says the executable has no DWARF info (says it's "empty"), which is what I would expect. But if I then run dsymutil on it, it creates non-empty symbol files. These are binary files so I don't know what's in them. Can anyone enlighten me on this? Are there any viewers for these files?
Yes, there is additional information. Note that the .dSYM file is actually a directory. Inside you will find:
SomeApp.app.dSYM/Contents/Info.plist
SomeApp.app.dSYM/Contents/Resources/DWARF/SomeApp
Be aware that you need to keep the exact .dSYM and .app bundle that was created when you made the release build. Even if the code hasn't changed, the .dSYM from a separate build won't match up because apple generate a unique id for each build you do.

Time profiler doesn't show me functions

In tutorial, when someone debug app they see something like this:
But when i start recording, by pressing red button:
I see this...
Make sure the Generate Debug Symbols build setting is set to Yes. You need debug symbols to have function names appear in Instruments.
If your project is generating debug symbols, Instruments may not be able to find your project's dSYM file. In Instruments choose Instrument > Call Tree Data Mining > Locate dSYM file to find and open your project's dSYM file. Your project's dSYM file is usually located in the same directory as the application bundle of your project's release version. Additional information can be found in the following article:
Instruments: Locating dSYM Files
I had 2 different versions of Xcode 9.4.1 and 10.1 both of them had command line tools which were in conflict(i suppose). To fix this issue I set right command line tools version there:
"Xcode -> Preferences -> Locations tab -> Command line tools".
Also check Build Settings and set "DWARF with dSYM File" to your target.

Resources