JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.39k stars 1.18k forks source link

Build iOS project (undefined symbol _OBJC_CLASS_$_CMPAccessibilityContainer) with 1.6.11 #5059

Closed DJ-LEE11 closed 4 months ago

DJ-LEE11 commented 5 months ago

Describe the bug Undefined symbol when Build iOS project(_OBJCCLASS$_CMPAccessibilityContainer).

Affected platforms

Versions

Full output 11:26:31 ld: warning: object file (/opt/data/DUOWAN_BUILD/bdgameassist/assist_2.73_kmm_feature/Pods/ultron/libs/libultron.a[arm64]67) was built for newer 'iOS' version (13.2) than being linked (13.0) 11:26:31 ld: warning: object file (/opt/data/DUOWAN_BUILD/bdgameassist/assist_2.73_kmm_feature/Pods/ultron/libs/libultron.a[arm64]68) was built for newer 'iOS' version (13.2) than being linked (13.0) 11:26:31 ld: warning: Could not find or use auto-linked framework 'AFNetworking': framework 'AFNetworking' not found 11:26:31 ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found 11:26:31 ld: warning: Could not find or use auto-linked framework 'TYRZSDK': framework 'TYRZSDK' not found 11:26:31 ld: Undefined symbols: 11:26:31 _OBJCCLASS$_CMPAccessibilityContainer, referenced from: 11:26:31 in bdgameshared[arm64]2 11:26:31 _OBJCCLASS$_CMPAccessibilityElement, referenced from: 11:26:31 in bdgameshared[arm64]2 11:26:31 _OBJCCLASS$_CMPEditMenuView, referenced from: 11:26:31 in bdgameshared[arm64]2 11:26:31 _OBJCCLASS$_CMPInteropWrappingView, referenced from: 11:26:31 in bdgameshared[arm64]2 11:26:31 _OBJCCLASS$_CMPViewController, referenced from: 11:26:31 in bdgameshared[arm64]2 11:26:31 clang: error: linker command failed with exit code 1 (use -v to see invocation)

KMM build.gradle kotlin { ...

listOf(
    iosArm64(),
).forEach {
    val main by it.compilations.getting {
        val fixUndefinedSymbols by cinterops.creating {
            defFile(project.file("src/iosArm64Main/cinterop/fix_undefined_symbols.def"))
        }
    }
    it.binaries.framework {
        baseName = artifactName
        isStatic = true
        transitiveExport = true
        export("tv.athena.baizhankmm:basesdk:${properties["kmm_basesdk"]}")
        export("tv.athena.bdgamekmm:homepageapi:${properties["kmm_homepage"]}")
        export("tv.athena.bdgamekmm:baseliveapi:${properties["kmm_baselive"]}")
    }
}

val publicationsFromMainHost =
    listOf(
        iosArm64(),
    ).map { it.name } + "kotlinMultiplatform"

if (version.toString().contains("SNAPSHOT")) {
    logger.log(LogLevel.INFO, "current is testing version")
} else {
    logger.log(LogLevel.INFO, "current is release version")
}

publishing {
    publications {
        matching { it.name in publicationsFromMainHost }.all {
            val targetPublication = this@all
            tasks.withType<AbstractPublishToMaven>()
                .matching { it.publication == targetPublication }
                .configureEach { onlyIf { false } }
        }
    }
}

// Create a task to build a framework.
tasks.register<FatFrameworkTask>("releaseIOSFramework") {
    baseName = artifactName
    destinationDir = buildDir.resolve("ios_frameworks")
    from(
        iosArm64().binaries.getFramework("RELEASE")
    )
}

targets.withType<KotlinNativeTarget> {
    binaries.all {
        freeCompilerArgs += "-Xgc=cms"
        freeCompilerArgs += "-Xpurge-user-libs"
        freeCompilerArgs += "-Xno-inline"
        freeCompilerArgs += "-Xoverride-konan-properties=clangOptFlags.ios_arm64=-Oz -flto=full"
        freeCompilerArgs += "-Xexport-kdoc"
    }
}
...

}

igordmn commented 4 months ago

Moved to https://youtrack.jetbrains.com/issue/CMP-5059/Build-iOS-project-undefined-symbol-OBJCCLASSCMPAccessibilityContainer-with-1.6.11. Please see the comment there.

okushnikov commented 4 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.