Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin 1.8.0 compile error #48

Open
brendanw opened this issue Feb 1, 2023 · 6 comments
Open

Kotlin 1.8.0 compile error #48

brendanw opened this issue Feb 1, 2023 · 6 comments

Comments

@brendanw
Copy link

brendanw commented Feb 1, 2023

After updating a project to kotlin 1.8.0, I started seeing the below error

Showing Recent Messages
Undefined symbols for architecture arm64:

  "_OBJC_CLASS_$_Bugsnag", referenced from:
      objc-class-ref in libco.touchlab.crashkios:bugsnag-cache.a(result.o)
      objc-class-ref in libco.touchlab:kermit-bugsnag-cache.a(result.o)
  "_OBJC_CLASS_$_BugsnagError", referenced from:
      objc-class-ref in libco.touchlab.crashkios:bugsnag-cache.a(result.o)
  "_OBJC_CLASS_$_BugsnagFeatureFlag", referenced from:
      objc-class-ref in libco.touchlab.crashkios:bugsnag-cache.a(result.o)
  "_OBJC_CLASS_$_BugsnagStackframe", referenced from:
      objc-class-ref in libco.touchlab.crashkios:bugsnag-cache.a(result.o)

The project does not directly depend on crashkios, just has a dependency on kermit:

            implementation("co.touchlab:kermit:1.2.2")
            implementation("co.touchlab:kermit-bugsnag:1.2.2")
@russhwolf
Copy link
Contributor

Are you using cocoapods? Kotlin 1.8 changes the cocoapods plugin to link dynamically instead of statically by default, and this looks like a linking error. If that's the issue, the fix is to do

cocoapods {
  framework {
    isStatic = true
  }
}

If that's not the issue, it would help to know more about your project.

@kpgalligan
Copy link
Contributor

Kermit bugsnag depends on crashkios for cinterop. We still need more doc updates, but here's the linker error you're getting:

https://github.com/touchlab/Kermit/blob/main/kermit-bugsnag/README.md#testing

You'll need to either make the framework static as Russell suggests, or tell the linker to ignore those missing symbols. If you're testing, you'll need to disable the build cache:

kotlin.native.cacheKind.iosX64=none
kotlin.native.cacheKind.iosSimulatorArm64=none

@brendanw
Copy link
Author

brendanw commented Feb 5, 2023

Thanks Russ and Kevin!

Yes, I am using cocoapods.

Switching back to static linking resolves the issue.

I tried following the instructions for using co.touchlab.crashkios.bugsnaglink but was unable to successfully build. Spent some time experimenting toggling various gradle/kotlin flags in gradle.properties to no avail.

@ponvig
Copy link

ponvig commented Feb 17, 2023

Have similar issues trying to add the library for crashlytics to my KMM project. The gradle plugin suggested in https://github.com/touchlab/CrashKiOS#linking did not resolve the problem. (Not using cocoapods) Any chance you could validate and update the documentation using a fresh KMM 1.8.0 project?

@amirplaza
Copy link

amirplaza commented Apr 18, 2023

@ponvig It seems the plugin adding compiler parameters doesn't work properly on Kotlin 1.8.10.
As a workaround I added the following line to "iosArm64().binaries.framework {" piece of code.

freeCompilerArgs += listOf("-linker-options", "-U _FIRCLSExceptionRecordNSException -U _OBJC_CLASS_\$_FIRStackFrame -U _OBJC_CLASS_\$_FIRExceptionModel -U _OBJC_CLASS_\$_FIRCrashlytics")

Note: instead of using iosArm64(), you will probably iterate over all of the supported native targets.

I suppose something similar happens with the Bugsnag plugin.

@kirillzh
Copy link

kirillzh commented Sep 3, 2023

Was hoping to enable K/N caching as well but am running into similar problem... Using Kotlin 1.9.0, Compose 1.5.0 (supports K/N caching finally), static library linking, not using cocoapods:

16:44:51 Please try to disable compiler caches and rerun the build. To disable compiler caches, add the following line to the gradle.properties file in the project's root directory:
16:44:51     
16:44:51     kotlin.native.cacheKind.iosX64=none
16:44:51     
16:44:51 Also, consider filing an issue with full Gradle log here: https://kotl.in/issue
16:44:51 The /Applications/Xcode/14.2.0/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
16:44:51 output:
16:44:51 Undefined symbols for architecture x86_64:
16:44:51   "_OBJC_CLASS_$_Bugsnag", referenced from:
16:44:51       objc-class-ref in libco.touchlab.crashkios:bugsnag-cache.a(result.o)
16:44:51   "_OBJC_CLASS_$_BugsnagError", referenced from:
16:44:51       objc-class-ref in libco.touchlab.crashkios:bugsnag-cache.a(result.o)
16:44:51   "_OBJC_CLASS_$_BugsnagFeatureFlag", referenced from:
16:44:51       objc-class-ref in libco.touchlab.crashkios:bugsnag-cache.a(result.o)
16:44:51   "_OBJC_CLASS_$_BugsnagStackframe", referenced from:
16:44:51       objc-class-ref in libco.touchlab.crashkios:bugsnag-cache.a(result.o)
16:44:51 ld: symbol(s) not found for architecture x86_64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants