Ship an XCFramework for iOS
Build a distributable framework for Swift consumers.
Ship an XCFramework for iOS is a free Kotlin Multiplatform Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Multiplatform Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
iOS Needs a Framework
Swift consumers cannot use a Maven JAR. They expect an Apple-native bundle, and the modern format for that is the XCFramework. 🍎
What an XCFramework Is
An XCFramework packages compiled binaries for several architectures in one bundle, so it works on devices and simulators alike.
Why Not a Plain Framework
An old fat framework mixed device and simulator slices and broke on Apple Silicon. The XCFramework keeps each slice separate and clean.
Declare Your iOS Targets
List the iOS targets you support in the kotlin block. Each one becomes a slice inside the final XCFramework bundle.
kotlin {
iosArm64()
iosSimulatorArm64()
}Name the Framework
Give your framework a clear baseName. Swift code imports it by exactly this name, so pick something the iOS team will recognize.
binaries.framework {
baseName = "Shared"
}Build the XCFramework
The Kotlin plugin adds an assembleXCFramework task that compiles every iOS target and bundles them together for you.
./gradlew :shared:assembleSharedXCFrameworkStatic vs Dynamic
A static framework links into the app at build time, while a dynamic one loads at launch. Static is the common default for KMP libraries.
Find the Output
The finished bundle lands in your build folder as Shared.xcframework. That single file is what iOS developers will integrate.
Add It in Xcode
iOS devs drag the bundle into their project and add it under Frameworks. From there, Swift can import and call your shared API.
import Shared
let greeting = Greeting().greet()Distribute as a Zip
For sharing, zip the bundle and host it somewhere downloadable. A checksum lets consumers verify the file arrived intact.
Rebuild on Every Change
The XCFramework is a snapshot of your code. After shared changes, reassemble it so iOS gets the latest logic instead of stale binaries.
Quick Check
Let's check your iOS packaging knowledge.
Recap
Declare your iOS targets, name the framework, run assembleXCFramework, then hand the bundle to Xcode for Swift to import. 🎉
Frequently asked questions
Is the “Ship an XCFramework for iOS” lesson free?
Yes — the full text of “Ship an XCFramework for iOS” is free to read here on the web, and the Kotlin Multiplatform Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Kotlin Multiplatform Academy course, upgrade to CoddyKit PRO.
What will I learn in “Ship an XCFramework for iOS”?
Build a distributable framework for Swift consumers. You practise Kotlin Multiplatform Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Kotlin Multiplatform Academy?
No prior experience is required. Kotlin Multiplatform Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Ship an XCFramework for iOS” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Kotlin Multiplatform Academy lesson?
Yes. Every Kotlin Multiplatform Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Configure maven-publish for KMP
- Ship an XCFramework for iOS
- Versioning & API Stability
- Release to Maven Central & SPM