After the release of Kotlin 1.5.30, there have been some significant changes for iOS support. As you can see, before Kotlin 1.5.30, we just need to define iosMain in our build.gradle.kts file, because every 64-bit software under iOS arm64 machine will run under Rosetta.
On Kotlin 1.5.30 onward, we need to define iosArm64Main and iosX64Main inside our build.gradle.kts’s sourceSets. The keyword dependsOn indicates that iosArm64 and iosX64 will use the dependencies of commonMain as well.
If you are interested in the Kotlin 1.5.30 release, you may go here for further information.
Configuration for iOS support
- Make sure you set the ios keyword inside kotlin lambda.
- Define iosX64Main for iOS 64 bit support inside sourceSets lambda.
- Define iosArm64Main for iOS arm64 support inside sourceSets lambda.
- Add iosMain and wrap it with iosX64Main and iosArm64Main.
- Publish to Maven Local.
- Verify there are x64 and arm64 distribution in your local .m2 folder. The naming convention is following <package-name>-(ios|iosarm64|iosx64).
After we finished setup Android and iOS, is time to get ready to publish our artifacts to Maven Central.
Publish to Maven Central is not straightforward as NPM publication, it required certain steps to follows. If you want a quick solution, maybe you can try this plugin out.
Ok, enough for today. We will continue on the next article for Maven Central publication. If you don’t want to miss out, kindly follow me on Medium. 😊
Part 1 — https://sianloong90.medium.com/step-by-step-build-a-kotlin-multiplatform-library-sdk-part-1-e973bdbfa55d
Part 2 — https://sianloong90.medium.com/step-by-step-build-a-kotlin-multiplatform-library-sdk-part-2-1d3a2f58dce1