getsentry / sentry-kotlin-multiplatform

Sentry SDK for Kotlin Multiplatform
MIT License
119 stars 18 forks source link

Build failed for iOS: Undefined symbols for architecture arm64: "_OBJC_CLASS_$_SentryId" #211

Closed k-ogawa-1988 closed 1 week ago

k-ogawa-1988 commented 2 weeks ago

Platform

Apple, Android

Installed

Swift Package Manager

Version

0.5.0

Steps to Reproduce

  1. Add io.sentry:sentry-kotlin-multiplatform:0.5.0 to sourceSets.commonMain.dependencies in build.gradle.kts
kotlin {
    // snip

    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach { iosTarget ->
        iosTarget.binaries.framework {
            baseName = "ComposeApp"
            isStatic = true
        }
    }

    sourceSets {
        commonMain.dependencies {
            implementation("io.sentry:sentry-kotlin-multiplatform:0.5.0")
        }
    }
}
  1. Add sentry-cocoa using sentry-wizard -i ios

  2. Move initialize code using Shared initializer

// commonMain/SentryInit.kt

fun initializeSentry() {
    Sentry.init { /* setting */ }
}
// androidMain/MainApplication.kt
class MainApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        initializeSentry()
    }
}
// iosMain/iOSApp.swift
import ComposeApp

@main
struct iOSApp: App {
    init() {
        SentryInitKt.intializeSentry()
    }
}
  1. Build both Android (on Android Studio) and iOS (on XCode)

Expected Result

Build success.

Actual Result

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_SentryId", referenced from:
       in ComposeApp[arm64][2727](libio.sentry:sentry-kotlin-multiplatform-cache.a.o)
ld: symbol(s) not found for architecture arm64
buenaflor commented 2 weeks ago

Hi which version of cocoa sdk are you using?

buenaflor commented 2 weeks ago

Not sure which version is added through the wizard

buenaflor commented 2 weeks ago

We might have to update our KMP SDK to handle sentry cocoa versions higher than 8.22.0

Otherwise we recommend installing the KMP SDK as per our guide: https://docs.sentry.io/platforms/kotlin-multiplatform/

buenaflor commented 1 week ago

This problem should be fixed with the next release 0.6.0

k-ogawa-1988 commented 1 week ago

which version of cocoa sdk are you using?

Using 8.25.0.

I'll try using cocoapods.

buenaflor commented 1 week ago

fyi currently our KMP SDK only works with versions up to 8.21.0, please look at this table to check what works

buenaflor commented 1 week ago

Our next release will support versions starting from 8.22

buenaflor commented 1 week ago

Fixed by 0.6.0.

Feel free to comment if there is still an issue

k-ogawa-1988 commented 1 week ago

@buenaflor It works now, thank you!