Symbol not found at runtime
Platform
Apple
Installed
Swift Package Manager
Version
0.18.0 and 0.19.0
Steps to Reproduce
I followed the instructions here to add the gradle plugin: https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/. I set the version in swift package manager for the sentry to 8.55.1 when using sentry-kotlin-multiplatform 0.19.0, then when that had the runtime error below, I switched to 0.18.0 and 8.53.2, but I see the same issue.
The sentry gradle plugin is in the plugins list in the build.gradle.kts file in the shared module.
My sentry setup code is in commonMain and is pretty simple:
package com.withandy.mobile
import io.sentry.kotlin.multiplatform.Sentry
fun initializeSentry(dsn: String, environment: String) {
Sentry.init { options ->
options.dsn = dsn
options.environment = environment
}
}
I get this runtime error when I run the iOS app on the simulator (I haven't tried a real device):
dyld[98376]: Symbol not found: _OBJC_CLASS_$_PrivateSentrySDKOnly
Referenced from: <1815E9D7-C028-3BDF-960C-0EEEDAC6B7B1> /Users/samueljudd/projects/oasis/android/mobile/build/xcode-frameworks/Debug/iphonesimulator18.2/andyMobileKit.framework/andyMobileKit
Expected in: <BC577ED8-A8DE-3D33-B514-B2EE3D6727A1> /Users/samueljudd/Library/Developer/CoreSimulator/Devices/ADFE8CFF-D60B-4231-9D10-75A5CDAB02A6/data/Containers/Bundle/Application/D5923DB2-B38D-4FD4-BDC6-5048DF03B49F/VisitRecorder.app/Frameworks/Sentry.framework/Sentry
Expected Result
I'd like it to not crash at runtime
Actual Result
It crashes
hi which xcode version are you using?
Hi, I'm using Xcode 16.2 (16C5032a)
For what it's worth, I tried updating to 16.4 and now I'm running into a linker issue:
Showing All Messages
> Task :mobile:linkDebugFrameworkIosSimulatorArm64
The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
ld: framework 'Sentry' not found
> Task :mobile:linkDebugFrameworkIosSimulatorArm64 FAILED
> Task :mobile:skieUploadAnalyticsDebugFrameworkIosSimulatorArm64
/Users/x/projects/y/ios/ld:1:1: ignoring duplicate libraries: '-ldl'
[Incubating] Problems report is available at: file:///Users/samueljudd/projects/oasis/android/build/reports/problems/problems-report.html
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mobile:linkDebugFrameworkIosSimulatorArm64'.
> Compilation finished with errors
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.11.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 1m 11s
8 actionable tasks: 8 executed
Compilation finished with errors
Alternatively people also found success using the new spmForKmp plugin.
Unfortunately I cannot reproduce this issue but I'd also recommend clearing caches, deriveddata etc.. as well before and make sure that your Sentry Cocoa dependency in SPM is set to the exact version