This plugin has been archived in favour of KMP Framework Bundler. You can find a migration guide here
KMP FatFramework Cocoa is a Gradle plugin for Kotlin Multiplatform projects that generates a FatFramework for iOS targets, or a XCFramework for Apple targets and manages the publishing process in a CocoaPod Repository.
The library is uploaded on MavenCentral, so you can easily add the dependency on the plugins
block:
plugins {
id("com.prof18.kmp.fatframework.cocoa") version "<latest-version>"
}
The plugin adds five Gradle tasks to your project.
-
buildDebugIosFatFramework
that creates a FatFramework with theDebug
target. -
buildDebugXCFramework
that creates a XCFramework with theDebug
target. -
buildReleaseIosFatFramework
that creates a FatFramework with theRelease
target. -
buildReleaseXCFramework
that creates a XCFramework with theRelease
target. -
generateCocoaPodRepo
that generates a CocoaPod repository ready to host the Framework. -
publishDebugIosFatFramework
that publishes theDebug
version of the FatFramework in the CocoaPod repository. -
publishDebugXCFramework
that publishes theDebug
version of the XCFramework in the CocoaPod repository.
The "publishDebug" task (for both the type of frameworks) takes care of everything:- changing the working branch from main/master to develop;
- building the debug framework;
- updating the version name inside the Podspec file;
- committing the changes;
- and publishing to remote.
In this way, in the iOS project, you can use the latest changes published on the develop branch:
pod '<your-library-name>', :git => "git@github.com:<git-username>/<repo-name>.git", :branch => 'develop'
To run this task, the output path provided in the configuration must be a git repository.
-
publishReleaseIosFatFramework
that publishes theRelease
version of the FatFramework in the CocoaPod repository. -
publishReleaseXCFramework
that publishes theRelease
version of the XCFramework in the CocoaPod repository.
The "publishRelease" task (for both the type of frameworks) takes care of everything:- changing the working branch from develop to main/master;
- building the release framework;
- updating the version name inside the Podspec file;
- committing the changes;
- tagging the commit;
- and publishing to remote.
In this way, in the iOS project, you have to specify a version:
pod '<your-library-name>', :git => "git@github.com:<git-username>/<repo-name>.git", :tag => '<version-number>'
To run this task, the output path provided in the configuration must be a git repository.
You can configure the plugin with the fatFrameworkCocoaConfig
block in your build.gradle[.kts]
.
The mandatory fields are three:
- the name of the FatFramework
- the output path
- the version name
- For XCFramework support, you need to set the
useXCFramework
flag. When the flag is set, only the XCFramework task can be called.
fatFrameworkCocoaConfig {
frameworkName = "LibraryName"
outputPath = "$rootDir/../test-dest"
versionName = "1.0"
useXCFramework = true
}
When using a FatFramework, only iOS targets can be packed together. With XCFramework you can pack together all the Apple families: iOS, macOS, etc.
If you want to run the generateCocoaPodRepo
task to generate a CocoaPod repository, you have to
provide the mandatory fields mentioned above and some other parameters in the cocoaPodRepoInfo
block:
- a summary of the library
- the homepage of the library
- the license of the library
- the authors of the library
- the url of the git repository that hosts the CocoaPod repo.
fatFrameworkCocoaConfig {
frameworkName = "LibraryName"
outputPath = "$rootDir/../test-dest"
versionName = "1.0"
cocoaPodRepoInfo {
summary = "This is a test KMP framework"
homepage = "https://github.com/prof18/ccoca-repo-test"
license = "Apache"
authors = "\"Marco Gomiero\" => \"mg@mail.it\""
gitUrl = "git@github.com:prof18/ccoca-repo-test.git"
}
}
- The version
0.2.1
introduce some breaking changes to better support XCFrameworks. Give a look to the 0.2.1 release notes.
To see the plugin in action, I've published a little sample project.
This plugin is born from a set of unbundled Gradle tasks that I was copying between every Kotlin Multiplatform project. I've written about these tasks in an article on my website.
For more info about CocoaPod repo, I suggest reading the following resources:
Copyright 2021 Marco Gomiero
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.