-
Notifications
You must be signed in to change notification settings - Fork 7
Kaluga 0.3.0 Migration (Apple Silicon Targets)
Since version 0.3.0
we have introduced the new Apple Silicon targets ( only iOS for now, macOS will follow soon ) support which means that the way we were declaring iOS targets in build.gradle
has changed along with Xcode framework setup. Following you'll find a guideline to how make your project compatible with this new version of Kaluga and this new settings is the new base from now on on all our projects.
All project dependencies or submodules MUST support Apple Silicon or have the same changes described in this guideline in order to have the whole project build properly.
In this file we need to add the iosSimulatorArm64
target.
...
var sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
val isArm64 = sdkName.startsWith("iphoneos") // <-- from KMM generated project, but a bit suspect
val iosArchitecture = if (isArm64) { "Arm64" } else { "X64" }
...
extra["sdkName"] = sdkName
extra["isArm64"] = isArm64
extra["iosArchitecture"] = iosArchitecture
...
Or any other static reference to iOS targets
val target: KotlinNativeTarget.() -> Unit = ...
ios(configure = target)
or
ios()
with
iosX64(configure = target)
iosArm64(configure = target)
iosSimulatorArm64(configure = target)
or
iosX64()
iosArm64()
iosSimulatorArm64()
There is no need anymore to reference the dir since the new way with dependOn
does it.
named("ios${iosArchitecture}Main") {
kotlin.srcDirs("src/iosMain/kotlin")
}
named("ios${iosArchitecture}Test") {
kotlin.srcDirs("src/iosTest/kotlin")
}
or
val iosMain by getting
val iosTest by getting
with
val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}
val iosX64Test by getting
val iosArm64Test by getting
val iosSimulatorArm64Test by getting
val iosTest by creating {
dependsOn(commonTest)
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
Remove all the reference about the shared framework in all Xcode targets from this panel:
Either in Build Phases
or in xcconfig
files if you are using those, replace the gradlew
script with the follow one
# Root where to run gradlew
cd "$SRCROOT/../"
# Select which module needs to run the task
./gradlew :YOUR_MODULE_NAME:embedAndSignAppleFrameworkForXcode
If in your old script there were some User-Defined
properties, just remove them as well in your Build Settings
. Just scroll to the very bottom of Build Settings
and check them under User-Defined
.
Either in Build Settings
or in xcconfig
files if you are using those, replace the FRAMEWORK_SEARCH_PATHS
with
# Select from which module needs to get the framework
$(SRCROOT)/../YOUR_MODULE_NAME/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)
In Other Linker flags
under the Linking
section:
$(inherited) -framework shared
In case you get KOTLIN_FRAMEWORK_BUILD_TYPE
error while building, just add that in your User-Defined
inside Build Settings
as below: