sentry-kotlin-multiplatform: Test Apple targets don't find Sentry framework when using SPM

Platform

Apple, Android

Installed

Swift Package Manager

Version

0.4.0

Steps to Reproduce

  1. Add Sentry KMP dependency to commonMain
  2. Add a simple test to commenTest
  3. Run linkDebugTestIosSimulatorArm64 Gradle task or run test on iOS simulator target

See fork from my co-worker: https://github.com/PaulWoitaschek/sentry-kotlin-multiplatform/commit/4e856fc11414ad2a1ee44f40d4e189b7b639698e

Expected Result

Test also runs on Apple targets as expected

Actual Result

Gradle task linkDebugTestIosSimulatorArm64 fails with error message: ld: framework 'Sentry' not found

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Reactions: 1
  • Comments: 22 (9 by maintainers)

Most upvoted comments

Turns out someone raised this in the past too 😂 https://github.com/getsentry/sentry-cocoa/issues/1623

Got it, yea, will definitely add it to our docs. If that doesn’t work in your use case we’d prolly have to wait until the kotlin folks deliver a proper swiftpm solution similar to their cocoapods plugin.

The other option would be to create a gradle plugin and add this workaround automatically

Crashkios has solved this by basically telling the linker to treat the listed symbols as undefined. That means the linker will not try to find these symbols during the linking process and assumes these symbols will be provided by other means.

I would like to mention that tricking the linker like that results in issues when you distribute your app with app thinning enabled.

Besides that, last I heard, the CrashKiOS approach hasn’t been working for tests in recent Kotlin versions either.

@rickclephas is deprecating the sentry integration and point to using this SDK.

Yeah, like @buenaflor already mentioned, NSExceptionKt currently suffers from the same issue. I have been working on a new API that will decouple the implementations from the Kotlin code. The Sentry implementation requires a lot of private APIs, and is no longer needed since there is this official SDK, so I indeed decided to deprecate it.

@msasikanth No, not yet. Since we already have a working solution by using the native libraries on each platform separately we’ve investigated not further and blocking the integration of the KMP version until there is a fix from Sentry

Hey @buenaflor !

Were you able to already take a look at this issue?

It would be great if it was documented https://docs.sentry.io/platforms/kotlin-multiplatform/#swift-package-manager-spm that if you’re using that option it’s no longer possible to run tests.