Introducing KMP FatFramework Cocoa, a Gradle plugin for iOS FatFramework
Today I want to share KMP FatFramework Cocoa, a Gradle plugin for Kotlin Multiplatform projects that generate a FatFramework for iOS targets and manages the publishing process in a CocoaPod Repository.
The plugin is born from a set of unbundled Gradle tasks that I wrote to manage the building and the publishing process of Kotlin Multiplatform libraries for iOS that we use at Uniwhere and Revelop. The libraries are published in a FatFramework that contains the code for every required architecture (real devices use the Arm64 architecture, while the simulator uses the host computer architecture which in most of the cases is X64).
After copying and pasting the task between different projects, I thought that having them bundled into a Gradle plugin, would be a good idea.
The plugin is composed of a bunch of tasks that let you build the FatFramework with the
Release target, publish both the versions to a CocoaPod repository, and also create the repository.
The task that publishes the debug version of the FatFramework will use the
develop branch of the CocoaPod repository, while the task for the release version will use the
master) branch and it will also tag the release with the provided version number. In this way, in the iOS project you can get the latest changes published on the develop branch:
pod '<your-library-name>', :git => "email@example.com:<git-username>/<repo-name>.git", :branch => 'develop'
or specify a tag to get the release version:
pod '<your-library-name>', :git => "firstname.lastname@example.org:<git-username>/<repo-name>.git", :tag => '<version-number>'
For all the details about the tasks and the required configurations, you can give a look at the documentation on the GitHub repo. Instead, if you are interested in the internals of the tasks, I’ve recently written an article about the topic.
This is my first Gradle plugin and I’ve learned a lot during the process. If you notice a bug or something strange, feel free to report it on GitHub or to contribute (contributions are always appreciated).
And, if you have any suggestion or any kind of doubt, feel free to reach me out on Twitter @marcoGomier.