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

Linker plugin not working with the new Kotlin/Native artifacts DSL #46

Open
joharei opened this issue Jan 6, 2023 · 2 comments
Open

Comments

@joharei
Copy link

joharei commented Jan 6, 2023

The linker plugin is not applying the compiler args when using the new DSL for Kotlin/Native artifacts: https://kotlinlang.org/docs/multiplatform-native-artifacts.html.

I can work around it by specifying the compiler args manually:

kotlinArtifacts {
    Native.XCFramework("sdk") {
        targets(iosX64, iosArm64, iosSimulatorArm64)
        setModules(
            project(":shared"),
            project(":lib")
        )

        // Add this:
        kotlinOptions {
            freeCompilerArgs = listOf(
                "-linker-options",
                "-U _FIRCLSExceptionRecordNSException " +
                        "-U _OBJC_CLASS_\$_FIRStackFrame " +
                        "-U _OBJC_CLASS_\$_FIRExceptionModel " +
                        "-U _OBJC_CLASS_\$_FIRCrashlytics"
            )
        }
    }
}
@sigurdurrafn
Copy link

sigurdurrafn commented Jan 17, 2023

I have the same issue.

I'm using the plugin id("co.touchlab.crashkios.crashlyticslink") version "0.8.1".

This was enough to fix the linker issue to build the app.

But the test linker task :linkDebugTestIosArm64 fails (also the x86 one). the error is the same as building the app without the plugin:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_FIRCrashlytics", referenced from:
      objc-class-ref in libco.touchlab.crashkios:crashlytics-cache.a(result.o)
  "_OBJC_CLASS_$_FIRExceptionModel", referenced from:
      objc-class-ref in libco.touchlab.crashkios:crashlytics-cache.a(result.o)
  "_OBJC_CLASS_$_FIRStackFrame", referenced from:
      objc-class-ref in libco.touchlab.crashkios:crashlytics-cache.a(result.o)
ld: symbol(s) not found for architecture arm64

@npresseault
Copy link

I've had the same issue. We're also using cocoapod gradle plugin.

I was able to workaround it by adding the linker options on the freeCompilerArgs of my Framework configuration

kotlin {
    cocoapods {
       framework {
            configureFramework()
        }
    }
}

fun org.jetbrains.kotlin.gradle.plugin.mpp.Framework.configureFramework() {
    isStatic = false
    freeCompilerArgs = listOf(
        "-linker-options",
        "-U _FIRCLSExceptionRecordNSException " +
            "-U _OBJC_CLASS_\$_FIRStackFrame " +
            "-U _OBJC_CLASS_\$_FIRExceptionModel " +
            "-U _OBJC_CLASS_\$_FIRCrashlytics"
    )

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

3 participants