Ein XCFramework für iOS ausliefern
Erstellen Sie ein verteilbares Framework für Swift-Nutzer.
Ein XCFramework für iOS ausliefern ist eine kostenlose Kotlin Multiplatform Academy-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Kotlin Multiplatform Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Kotlin Multiplatform Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
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. 🎉
Häufig gestellte Fragen
Ist die Lektion „Ein XCFramework für iOS ausliefern“ kostenlos?
Ja — der vollständige Text von „Ein XCFramework für iOS ausliefern“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Kotlin Multiplatform Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Kotlin Multiplatform Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Ein XCFramework für iOS ausliefern“?
Erstellen Sie ein verteilbares Framework für Swift-Nutzer. Du übst Kotlin Multiplatform Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Kotlin Multiplatform Academy zu starten?
Keine Vorkenntnisse erforderlich. Kotlin Multiplatform Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.
Wie lange dauert die Lektion „Ein XCFramework für iOS ausliefern“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Kotlin Multiplatform Academy-Lektion Code schreiben und ausführen?
Ja. Jede Kotlin Multiplatform Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- maven-publish für KMP konfigurieren
- Ein XCFramework für iOS ausliefern
- Versionierung und API-Stabilität
- Auf Maven Central und SPM veröffentlichen