Hey! :wave: Is it possible to distribute a KMP mod...
# multiplatform
n
Hey! 👋 Is it possible to distribute a KMP module as a pure Framework (or w/e the name is for Libraries in iOS ecosystem)? I would want my iOS counterparts not to have to build the module but receive it as a… Pod dependency? Is there any way to do this or it’s mandatory for them to have the Java SDK and such to build it locally?
a
It is possible to do this, and it's what we do most of the time at Quizlet
n
Could you point me in any direction to research? 🙏
a
Sure thing! We create an XCFramework for our shared code using these steps: https://kotlinlang.org/docs/mpp-build-native-binaries.html#build-xcframeworks We then copy in a standard podspec file into the same directory as the XCFramework a gradle
Copy
task. We declare the xcframework file as a
vendored_frameworks
and we also insert the project version number into the podspec using steps like this: https://blog.mrhaki.com/2010/10/gradle-goodness-parse-files-with.html Finally, we publish it to a private spec repo! You can follow some of the steps here: https://guides.cocoapods.org/making/private-cocoapods.html We personally just automate a git push though because we don't want to deal with ruby in our CI pipeline 🙃
K 2
n
Awesome, man. Thanks so much ❤️.
👍 1
a
Yup! You can also combine this with the local-build approach, which IMO gets the best of both worlds. We have our iOS app's Podfile set up to fetch a published artifact by default, but allow iOS engineers to also point to the local Podspec generated by the Cocoapods Gradle plugin This lets us • default to speedy iOS builds that consume pre-built KMP artifacts without iOS devs needing the JDK installed, • but also lets us quickly swap over to using local KMP code when we need to iterate quickly or debug issues. This pairs well with @kpgalligan’s https://github.com/touchlab/xcode-kotlin plugin for debugging too 🙂
n
Great idea! Thanks very much 🙂