Closed bjhomer closed 2 weeks ago
Sample project that reproduces the issue: SentryMacCrash.zip
Hello @bjhomer, this happens because the compiler is stripping the lib from unused code.
You can solve this by adding a reference to SentryCrashExceptionApplication
somewhere in your code just like this:
_ = SentryCrashExceptionApplication.shared
Right, and I noted that in my ticket. This should perhaps be documented, though, as right now, following the instructions leads to an app that won't launch.
Thanks for the feedback, we will implement your suggestion of having the reference inside Sentry SDK.
Platform
macOS
Environment
Production, Develop, TestFlight
Installed
Swift Package Manager
Version
8.25.0
Did it work on previous versions?
8.21.0
Steps to Reproduce
SentryCrashExceptionApplication
, as described here.See the attached sample project, which should reproduce the issue.
Expected Result
The app should launch when run.
Actual Result
The app crashes on launch. Nothing appears in the Xcode console, but in the macOS console, we see this:
I suspect that because there is no reference to
SentryCrashExceptionApplication
in the code, the class was never linked in from the static library, and thus is not present at runtime. If I add any reference toSentryCrashExceptionApplication
in the code, it launches correctly. For example, I can add this:Note, though, that if this reference were optimized out by the compiler, then the app might crash again. (Hence the need to actually
print
it.)It would be nice if Sentry itself could reference
SentryCrashExceptionApplication
on macOS, so that it is seen as a transitive dependency and thus would be linked in when other Sentry APIs are referenced. Alternatively, if referencingSentryCrashExceptionApplication
in code is necessary, this should be documented.Are you willing to submit a PR?
I'd be willing to, but it's not clear what route the team wants to take