I'm trying to cinterop a static .framework to use ...
# multiplatform
s
I'm trying to cinterop a static .framework to use it from Kotlin. Everything work well but when I build the composeApp, it get linking issue
Copy code
Undefined symbol: _OBJC_CLASS_$__TtC19TestStaticFramework19TestStaticFramework
But it shouldn't happen as it is a static library, I expect symboles to be included in the .framework generated by composeApp task. ######################### # DEF FILE #########################
Copy code
proprieties
language = Objective-C
modules = TestStaticFramework
package = swift.tsf
######################### # GRADLE IOS CONF #########################
Copy code
kotlin
listOf(iosArm64(), iosSimulatorArm64()).forEach { iosTarget ->

    iosTarget.binaries.framework {
        baseName = "ComposeApp"
        isStatic = true
    }

    val baseDir = "${rootDir.absolutePath}/TestStaticFramework/build/TestStaticFramework.xcframework"
    val frameworkDir = when (iosTarget.konanTarget) {
        KonanTarget.IOS_SIMULATOR_ARM64 -> "$baseDir/ios-arm64_x86_64-simulator"
        KonanTarget.IOS_ARM64 -> "$baseDir/ios-arm64"
        else -> error("Unsupported target: ${iosTarget.konanTarget}")
    }
    val frameworkPath = "$frameworkDir/TestStaticFramework.framework"

    val main by iosTarget.compilations.getting
    main.cinterops.create("TestStaticFramework") {
        defFile("${rootDir.absolutePath}/TestStaticFramework/TestStaticFramework.def")
        compilerOpts(
            "-F$frameworkDir",
            "-fmodules"
        )
    }

    iosTarget.binaries.all {
        linkerOpts(
            "-F$frameworkPath",
            "-framework",
            "TestStaticFramework"
        )
    }
}
######################### # Static Lib Symbole ######################### nm -gU TestStaticFramework #########################
Copy code
TestStaticFramework_vers.o:
0000000000000040 S _TestStaticFrameworkVersionNumber
0000000000000000 S _TestStaticFrameworkVersionString

TestStaticFramework.o:
0000000000000000 T _$s19TestStaticFrameworkAAC5helloSSyF
0000000000000140 T _$s19TestStaticFrameworkAAC5helloSSyFTj
000000000000021c S _$s19TestStaticFrameworkAAC5helloSSyFTq
0000000000000058 T _$s19TestStaticFrameworkAACABycfC
0000000000000078 T _$s19TestStaticFrameworkAACABycfc
00000000000000a8 T _$s19TestStaticFrameworkAACMa
00000000000001e8 S _$s19TestStaticFrameworkAACMn
00000000000001c8 S _$s19TestStaticFrameworkAACMo
0000000000000134 T _$s19TestStaticFrameworkAACMu
0000000000000388 S _$s19TestStaticFrameworkAACN
0000000000000104 T _$s19TestStaticFrameworkAACfD
00000000000001dc S _$s19TestStaticFrameworkMXM
0000000000000388 S _OBJC_CLASS_$__TtC19TestStaticFramework19TestStaticFramework
00000000000003e0 D _OBJC_METACLASS_$__TtC19TestStaticFramework19TestStaticFramework
00000000000001d8 S ___swift_reflection_version
0000000000000280 S __swift_FORCE_LOAD_$_swiftCompatibility56_$_TestStaticFramework
0000000000000268 S __swift_FORCE_LOAD_$_swiftCoreFoundation_$_TestStaticFramework
0000000000000270 S __swift_FORCE_LOAD_$_swiftDispatch_$_TestStaticFramework
0000000000000250 S __swift_FORCE_LOAD_$_swiftFoundation_$_TestStaticFramework
0000000000000260 S __swift_FORCE_LOAD_$_swiftObjectiveC_$_TestStaticFramework
0000000000000278 S __swift_FORCE_LOAD_$_swiftXPC_$_TestStaticFramework
0000000000000258 S __swift_FORCE_LOAD_$_swift_Builtin_float_$_TestStaticFramework
0000000000000224 S _symbolic So8NSObjectC
0000000000000232 S _symbolic _____ 19TestStaticFrameworkAAC
🧵 3
I have to add it to the xcode project (without embedding it) for it to link properly
Minimal reproduction project
t
@Timofey Solonin could you help here?
t
But it shouldn't happen as it is a static library, I expect symboles to be included in the .framework generated by composeApp task
Hey. This premise is wrong and this is not how K/N with cinterops (or the Swift/ObjC) linkage models work. If you want to deal with raw XCFrameworks/frameworks, your only options is to reinclude these artifacts at the linkage site - in Xcode
1
👍 1
s
I will try to merge them with ar