I'm trying to implement a library using Kotlin Multiplatform to use in my iOS project so I download the official library template, which implements a Fibonacci sequence.
I did only 2 changes in this project:
- I changed the Kotlin version from 1.9.0 to 1.9.21
- In the file
library/build.gradle.ktsI updated the targetiosSimulatorArm64()to output a.frameworkso I could use it on my Xcode iOS project, like this:
iosSimulatorArm64() {
binaries {
framework {
baseName = "TestLibrary"
}
}
}
Then I ran the command ./gradlew iosSimulatorArm64Binaries and the TestLibrary.framework was properly generated for me.
However, after I include this .framework in my project, my app crashes as soon as try to run the it (the Xcode project builds without any problem; it only crashes when I actually try to run the app), throwing this error:
I not even tried to run the Fibonacci code in the iOS project yet; the app crashes by simply adding the framework and trying to run the app. Any idea what is happening here?

I couldn't find a reason why my app is crashing when I create a
.frameworkand use it in Xcode, however I found a different solution that lets me achieve the same thing that I wanted to do originally: create a code in Kotlin Multiplatform and invoke this code in my iOS project using Swift.So, instead of creating a
.frameworkfile I decided to create a.xcframework. Then when I addedxcframeworkin my iOS project the app no longer crashed.To make your KMP library output a
.xcframeworkyou just need to update your build.gradle.kts file and add this: