https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
y

ynsok

01/31/2023, 4:12 PM
Hi, I have a multi-module application where
:core
behaves like an umbrella, And I would like to create a separate module just with analytics. But While I run gradle task
assembleXCFramework
I’m receiving this error:
Copy code
output:
Undefined symbols for architecture arm64:
 "_OBJC_CLASS_$_FIRCrashlytics", referenced from:
   objc-class-ref in result.o
ld: symbol(s) not found for architecture arm64
Also extra information is printed into the console with this information:
Copy code
> Task :core:linkDebugFrameworkIosArm64
w: Following libraries are specified to be exported with -Xexport-library, but not included to the build:
/Users/ynsok/AndroidStudioProjects/kmm-project/monitoring/build/libs/iosArm64/main/monitoring-cinterop-FirebaseCrashlytics.klib
Here is partial setup
build.gradle.kts
for
:monitoring
module
Copy code
val xcf = XCFramework()
    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = Module.Monitoring.simpleName
            xcf.add(this)
        }
    }

    cocoapods {
        summary = "This module contains implementation of analytics and crashlytics"
        name = Module.Monitoring.simpleName
        ios.deploymentTarget = application.IOSConfig.deployment_target
        version = application.IOSConfig.cocoapods_version
        homepage = application.IOSConfig.cocoapods_homepage
        license = application.IOSConfig.cocoapods_license

        framework {
            baseName = Module.Monitoring.simpleName
            embedBitcode = org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode.DISABLE
        }
        pod("FirebaseCrashlytics")
        podfile = project.file("../iosApp/Podfile")
    }
Here is partial setup
build.gradle.kts
for
:core
module
Copy code
val xcf = XCFramework()
listOf(
    iosX64(),
    iosArm64(),
    iosSimulatorArm64()
).forEach {
    it.binaries.framework {
        baseName = Module.Core.simpleName
        export(project(Module.Monitoring.dependencyName))
        xcf.add(this)
    }
}

cocoapods {
    summary = "The module contains core business logic for Pismo application"
    name = Module.Core.simpleName
    ios.deploymentTarget = application.IOSConfig.deployment_target
    version = application.IOSConfig.cocoapods_version
    homepage = application.IOSConfig.cocoapods_homepage
    license = application.IOSConfig.cocoapods_license

    framework {
        baseName = Module.Core.simpleName
        isStatic = false
        embedBitcode = org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode.DISABLE
        export(project(Module.Monitoring.dependencyName))
    }
    podfile = project.file("../iosApp/Podfile")
}
Any Idea what is wrong with this configuration ?
a

a-dd

01/31/2023, 4:29 PM
You need to provide a binary with symbols from
FirebaseCrashlytics
pod when linking the XCFramework. The simplest way to do it is to add this pod also to the
core
module’s
cocoapods
block. This adds a small overhead with unnecessary cinterop-generation but there will be new api that eliminates it in 1.8.20 (https://youtrack.jetbrains.com/issue/KT-41830) Or you can build a static framework from
core
module. You still will need to provide that binary when linking it into a final app though.
t

Tejeshwar Amirthy

04/11/2023, 4:27 AM
hey @a-dd I tried the above, getting the following errors and outputs. can you please help?
Copy code
e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors

The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
ld: '/kmmproject/build/cocoapods/synthetic/IOS/build/Release-iphoneos/gRPC-RxLibrary/RxLibrary.framework/RxLibrary' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file 

'/kmmproject/build/cocoapods/synthetic/IOS/build/Release-iphoneos/gRPC-RxLibrary/RxLibrary.framework/RxLibrary' for architecture arm64

> Task :kmm:linkPodDebugFrameworkIosSimulatorArm64
w: Following libraries are specified to be exported with -Xexport-library, but not included to the build:
a

a-dd

04/11/2023, 3:29 PM
It looks like you’re using Xcode 13 or below. You can upgrade to 14 or manually enable bitcode for the framework
t

Tejeshwar Amirthy

04/12/2023, 5:22 PM
I'm using Xcode 14.2
why do we need to enable bitcode? any specific reason?
i

Inder singh

07/01/2023, 10:48 AM
I am trying to add FirebaseDatabase & FirebaseCore as a pod dependencies but unable to build xcframwork
Copy code
cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "14.1"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "shared"
            isStatic = false
           
        }
        pod("FirebaseDatabase", moduleName = "FirebaseDatabase")
        pod("FirebaseCore", moduleName = "FirebaseCore")


        // Maps custom Xcode configuration to NativeBuildType
        xcodeConfigurationToNativeBuildType["debug"] = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG
        xcodeConfigurationToNativeBuildType["release"] = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.RELEASE
    }
Getting below error
Copy code
> Task :shared:linkDebugFrameworkIosArm64 FAILED
e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors

The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
ld: framework not found FirebaseDatabase
43 Views