getsentry / getsentry/sentry-dotnet
iOS apps not symbolicating in release mode
- Dominant language
- C#
- Stars
- 770
- Forks
- 248
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 49
Description
## Description
Symbolication / source context for stack traces is missing in release mode on iOS.
This is due to **a problem in the .NET SDK** when building for Apple platforms in release mode. This issue has been reported to Microsoft and is being tracked in the .NET runtime repository.
If this issue affects your application, please:
1. Visit the [.NET runtime issue](https://github.com/dotnet/runtime/issues/118700)
2. Add a reaction (👍) to indicate this affects you
3. Consider adding a comment describing your use case
This will help Microsoft prioritise the fix based on community impact.
### Workarounds
Until the issue is resolved properly, symbolication on Apple platforms is only possible by disabling stripping. For example, by adding the following to your `*.csproj` file(s):
```xml
false
```
**Important Note**: This may significantly increase the size of your application.
## Links
- [Minimal repro of the behaviour](https://github.com/jamescrosswell/is-portable)
- [Discord conversation](https://discord.com/channels/732297728826277939/732297808148824115/1404683708903981259)
- Tracking issue in the dotnet repository:
- https://github.com/dotnet/runtime/issues/118700
## Possible long term fix
In .NET 11 Microsoft are [previewing experimental support for CoreCLR on iOS](https://github.com/dotnet/macios/releases/tag/dotnet-11.0.1xx-preview3-11588). Since the linking issue that breaks the debug ids (the root cause for this issue) is likely one of the legacy tools used in the linking process in Mono, switching to CoreCLR could very well side step the issue entirely... 🤞🏻 need to test on .NET 11 when a stable preview is available (usually around preview 7).
## Further details (original issue report)
It looks like there's a mismatch in the Age field of the DebugID. For example, this is what is being uploaded to Sentry (portable PDB file):
```
sentry-cli debug-files check ./samples/Sentry.Samples.Maui/obj/Release/net9.0-ios18.0/iossimulator-arm64/Sentry.Samples.Maui.pdb
Debug Info File Check
Type: portablepdb debug companion
Contained debug identifiers:
> Debug ID: 38b96763-ba6a-469d-08f6-03cdcd8e4657-c17c59f
Arch: unknown
Contained debug information:
> debug, sources
Usable: yes
```
But in the event I'm seeing:
```json
"debug_id":"38b96763-ba6a-469d-08f6-03cdcd8e4657-1","debug_file":"/Users/jamescrosswell/code/sentry-dotnet/samples/Sentry.Samples.Maui/obj/Release/net9.0-ios18.0/iossimulator-arm64/Sentry.Samples.Maui.pdb"
```
If I run `sentry-cli debug-files find 38b96763-ba6a-469d-08f6-03cdcd8e4657-1`, I see:
```
38b96763-ba6a-469d-08f6-03cdcd8e4657-1 /Users/jamescrosswell/code/sentry-dotnet/samples/Sentry.Samples.Maui/obj/Release/net9.0-ios18.0/iossimulator-arm64/stripped/Sentry.Samples.Maui.dll [pe]
```
So the PE header for the stripped assembly that is actually running on the device has an Age field of `1`. However this is not a debug file (and can't be uploaded).
Contributor guide
Assessment
This issue has not been assessed yet.