hi, I'm experimenting with referencing a KMM frame...
# multiplatform
c
hi, I'm experimenting with referencing a KMM framework from within an iOS framework, I'm running
./gradlew :shared:embedAndSignAppleFrameworkForXcode
script at pre-compile time on the framework's project file and I'm getting this runtime error: dyld[87584]: Library not loaded: @rpath/shared.framework/shared I'm following this documentation https://kotlinlang.org/docs/multiplatform-mobile-integrate-in-existing-app.html#connect-the-framework-to-your-ios-project does anyone know what other build settings I'm missing here?
@kpgalligan
s
A couple of things could be wrong: • maybe the search path in the build settings in your Xcode project is not correct • maybe you are using a dynamic framework and the file can not be found after the project has been build. You would need to write a script to copy the binary manually to the correct place then Try to make the framework static in your build.gradle file. This could solve it.
k
Not sure. We pretty much never use the embed task. Just Cocoapods/SPM
k
@Cristina Suciu could you explain what you want to build? and show your build config the error says: your dynamic framework wasn’t found in
rpath
which usually points inside app bundle. the embed task copies framework to an app dir during a xcode build
c
@Konstantin Tskhovrebov I have a custom iOS framework that is running the
embedAndSignAppleFrameworkForXcode
at pre-compile time. I can create a sample project and I'll share it with you
k
kotlin framework is dynamic then you have to embed it together with your iOS framework to result app
c
@Konstantin Tskhovrebov how do I embedded it? I've used xcodegen to add the kmm framework as a dependency, but it fails at compile time. The custom script executing
embedAndSignAppleFrameworkForXcode
is ran later in the build process.
@kpgalligan <<Just Cocoapods/SPM>> do you just run the script to generate the KMM framework from terminal? Or do you integrate it in some other build process?
k
The default Cocoapods setup lets you build from Xcode and it handles the gradle calls to properly wrap things. The Android Studio template has a Cocoapods option (IIRC), or you can look at our basic sample: https://github.com/touchlab/KaMPKit
c
@Konstantin Tskhovrebov I'm following up on my attempt to embed a KMM framework into an iOS native framework, here's my fork of the kmm-production-sample repo https://github.com/Kotlin/kmm-production-sample/commit/8c22b421478dbd775e602acb215bbc33089cc197 How can RssReader KMM framework be embedded into the iOS framework using only the
embedAndSignAppleFrameworkForXcode
gradle task?
k
How can RssReader KMM framework be embedded into the iOS framework using only the
embedAndSignAppleFrameworkForXcode
gradle task?
there is no way, i think. 🤔 because this is a task for embedding a dynamic framework to a resulting application. try to build a XCFramework from the kotlin project and use it on the Xcode side https://kotlinlang.org/docs/multiplatform-build-native-binaries.html#build-xcframeworks
402 Views