touchlab / Kermit

Kermit by Touchlab is a Kotlin Multiplatform centralized logging utility.
https://kermit.touchlab.co
Apache License 2.0
702 stars 40 forks source link

I'm Getting an Error From the Sentury Plugin on The Native Build #267

Closed alexwhb closed 1 year ago

alexwhb commented 2 years ago

I'm using Kermit 1.1.3 with the co.touchlab:kermit-sentry plugin. Everything seems to work fine on Android, but on the native side it's not working properly. I've tried building for a real device as well and I get some other odd errors. It will sometimes build but then it gives

Here's what my error message looks like:

e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors

The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
ld: warning: object file (/var/folders/7k/tbdh_xjx3px9wr959xplg3yh0000gn/T/konan_temp10316344448197767467/result.o) was built for newer iOS Simulator version (14.0) than being linked (9.0)
Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_SentrySDK", referenced from:
      objc-class-ref in result.o
  "_OBJC_CLASS_$_SentryBreadcrumb", referenced from:
      objc-class-ref in result.o
ld: symbol(s) not found for architecture arm64

> Task :shared:linkPodDebugFrameworkIosSimulatorArm64 FAILED

FAILURE: Build failed with an exception.

Seems like maybe the Sentry arm64 binaries are not being built properly or something?

psh commented 1 year ago

Sentry is an iOS dynamic framework - the code will be there at runtime - so the linker only needs to be told that to ignore the symbols for now (using the -U option). You can do that in gradle by passing linker flags to the kotlin native compilation for the symbols you mentioned -

freeCompilerArgs += listOf("-linker-options", "-U _OBJC_CLASS_\$_SentrySDK")

and

freeCompilerArgs += listOf("-linker-options", "-U _OBJC_CLASS_\$_SentryBreadcrumb")

(Note: the $ is being escaped with an extra \)