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

Konstantin Petrukhnov

09/23/2019, 7:46 AM
After upgrading project from 1.3.31 (Konan, lipo linking) to 1.3.50 (MPP, fatframework task), tests stop working with error:
Copy code
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Only one Kotlin framework can be loaded currently'
*** First throw call stack:
Any suggestion how to fix it? App runs fine, only tests are failing. And tests were working before without any problem.
ios app is separate project using cocoapods. If I build only for arm64, it show same error.
o

olonho

09/23/2019, 8:17 AM
Likely your app ends up having two Kotlin frameworks linked in, which is not yet supported.
k

Konstantin Petrukhnov

09/23/2019, 8:57 AM
Only my lib is the kotlin fw in the project. And when I use older version of my lib, tests works. I suspect that there is some differences in fatframework task vs manual lipo.
so with konan, library was dynamically linked. With fat framework it is statically linked. +some bad configuration in our ios project podfile.
@olonho How do I build dynamic one (kotlin mpp)? Are there are some gradle configuration example?
k

Kris Wong

09/23/2019, 1:06 PM
i use a fat framework in my iOS app and it works with no issues
a

Artyom Degtyarev [JB]

09/23/2019, 1:22 PM
So, you were using cocoapods with 1.3.31, and the only difference is in the
FatFrameworkTask
? If so, you can somehow specify
isStatic
parameter for every native target with a binary of “framework” type e.g.
Copy code
kotlin {
    targets.withType<KotlinNativeTarget> {
        binaries.withType<Framework> {
            isStatic = false
        }
    }
}
k

Kris Wong

09/23/2019, 1:55 PM
i am not using cocoapods. the default for a framework target is to be dynamic.
the typical way i see to configure is:
Copy code
targets {
        configure([ios, iosArm32, iosArm64]) {
            binaries.framework {
                baseName = "$ios_framework_name"
            }
        }
    }
k

Konstantin Petrukhnov

09/24/2019, 4:26 AM
@Artyom Degtyarev [JB] We used 1.3.31 and Konan task and manual lipo linking. Now we using 1.3.50 and MPP structure and FatFramework task.
When i use "file build/fat-framework/MyFw.framework/MyFw", it output:
Copy code
Mach-O universal binary with 2 architectures: [x86_64:current ar archive random library] [arm64]
(for architecture x86_64):	current ar archive random library
(for architecture arm64):	current ar archive random library
When they linked dynamically, output is: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64] (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64 (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64
a

Artyom Degtyarev [JB]

09/24/2019, 8:11 AM
Can you share your gradle script? I cannot reproduce this result by myself, but this is not how everything was supposed to work.
k

Konstantin Petrukhnov

09/24/2019, 8:30 AM
2 Views