Hey everyone :wave: I know this question was asked...
# kotlin-native
l
Hey everyone 👋 I know this question was asked some time ago https://kotlinlang.slack.com/archives/C3SGXARS6/p1595286014228000 but I would like to revisit @João Gonçalves 🙏. I want to make a Kotlin/Native framework that could be easily consumed by iOS and Android apps. Currently I’m trying to setup iOS part, and I wanted to achieve Cocoapods support, so it will be easy to use on iOS side. The problem is that documentation on Kotlin/Native and most of the examples that I have found that uses
org.jetbrains.kotlin.native.cocoapods
plugin are focused on the scenario that the Android and iOS apps are in the same mono repo and iOS app consumes the Kotlin/Native framework locally - as the added
script_phases
runs gradlew to adjust the used framework. But when the framework is consumed from the github via cocoapods then there there is an error
gradlew: No such file or directory
(https://github.com/JetBrains/kotlin-native/issues/3140). The best would be if on the consumer side java/gralde/gradlew won’t be needed which probably would require Fat framework with (arm64 and x64 binaries)
I made a repository with 2 branches:
main
-> https://github.com/nonameplum/kotlin-native-framework/tree/main (it shows the issue of the default
script_phases
added by cocoapods kotlin/native plugin
the second branch
fixed_script
-> https://github.com/nonameplum/kotlin-native-framework/tree/fixed_script uses this fix https://github.com/JetBrains/kotlin-native/issues/3140 but it has a flaw that can’t be build on iOS simulator but can be on the device
Is the any repository that would show how to setup this correctly what I would like to achieve?
@basher 🙏
b
If you want to do it without gradle, then you'll want your CI to run FatFrameworkTask (example of this task) to generate a framework, and that will contain both iOS simulator and iOS device arch slices. From there, you create a podspec, and set the vendored_framework to the path to where your fat framework was generated. With that, you don't need a script phase
👍 4
l
@basher what about release/debug frameworks? What I’m aware of is to build separate two fat frameworks for debug and release (the release one could be only arm64 if it is not required to run on the simulator). Having that I could make two podspecs. One that would have as a vendor framework the release one and the second for debug. Is there a more convenient way?
b
Usually with vendored frameworks, you pick one: either a release or a debug framework (usually used for a 3rd party shipping a binary framework, in which case you ship a release frameework to your customers). You might be able to try configuration-based dependencies ("Build configurations" section here) and ship 2 pods (one release and one debug). I haven't tried this though
g
You might also want to take a look at my Gradle plugin that allows you to generate an xcframework. You can use SPM or Cocoapods to distribute it. https://github.com/ge-org/multiplatform-swiftpackage
Hi @Justin , glad you like the plugin 🙂 Thanks for your contribution. I like the addition and will look into the PR tomorrow
🙏 1