Uploading dSYM to Sentry
How to upload dsym artifacts to Sentry
Sentry is a crash reporting platform that provides you with real-time insight into production deployments with info to reproduce and fix crashes.
dSYM is used to symbolicate your crash reports. The purpose of dSYM is to replace symbols in the crash logs with the specific methods so it will be readable and helpful for debugging the crash.
A sample project showing how to upload dSYM files to Sentry can be found in our Sample projects repository.
Configure access to Sentry
In order to configure them correctly, a Sentry access token (SENTRY_ACCESS_TOKEN
) is required which can be found in your Sentry account after signing up. After getting the necessary token along with your organization name (SENTRY_ORGANIZATION_NAME
) and project name (SENTRY_PROJECT_NAME
), add them as environment variables in Codemagic.
Open your Codemagic app settings, and go to the Environment variables tab.
Enter the desired Variable name, e.g.
SENTRY_ACCESS_TOKEN
.Copy and paste the API token string as Variable value.
Enter the variable group name, e.g. sentry_credentials. Click the button to create the group.
Make sure the Secure option is selected.
Click the Add button to add the variable.
Repeat the steps to also add
SENTRY_ORGANIZATION_NAME
andSENTRY_PROJECT_NAME
variables.Add the variable group to your
codemagic.yaml
fileenvironment: groups: - sentry_credentials
Install Sentry dependency
To generate debug symbols with Sentry, a platform-specific dependency needs to be installed. Sentry provides different ways of installing the Sentry dependency according to which platform your app is built with. More information can be found in the Sentry documentation here.
The following example installs the dependency for React Native apps:
scripts:
- name: Install Sentry dependency
script: |
npm install --save @sentry/react-native
Specify artifacts path
As soon as your build finishes successfully, debug symbols are generated. However, if you want them to be displayed in the Codemagic UI build page, the following path needs to be configured in codemagic.yaml under the artifacts section:
artifacts:
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM
Publish to Sentry
In order to upload the dSYM files to Sentry, add the following script to your codemagic.yaml configuration file or to your post-publish script in the Flutter workflow editor:
scripts:
- name: Install Sentry dependency
script: |
echo "Find build artifacts"
dsymPath=$(find $CM_BUILD_DIR/build/ios/xcarchive/*.xcarchive -name "*.dSYM" | head -1)
if [[ -z ${dsymPath} ]]
then
echo "No debug symbols were found, skip publishing to Sentry"
else
echo "Publishing debug symbols from $dsymPath to Sentry"
sentry-cli --auth-token $SENTRY_ACCESS_TOKEN upload-dif \
--org $SENTRY_ORGANIZATION_NAME \
--project $SENTRY_PROJECT_NAME $dsymPath
fi
The above-mentioned dsymPath is React Native and Native iOS specific and it could change depending on what platform the app is built. For example, Flutter apps should use:
dsymPath=$(find $CM_BUILD_DIR/build/ios/archive/Runner.xcarchive -name "*.dSYM" | head -1)
If necessary, you can use remote access to the build machine to find the correct path. More information can be found here.