Sup every1:spock-hand: Case: M1 processor Multipla...
# multiplatform
m
Sup every1🖖 Case: M1 processor Multiplatform project with last changes from documentation ( migration to embedAndSignAppleFrameworkForXcode ) + last version of kotlin (1.5.30-release-411) Any type of ios config in gradle e.g.:
val ios = listOf(iosX64(), iosArm64())
configure(ios) {
binaries{
framework{
baseName = "commonModule"
}
}
}
...
...
val iosX64Main by getting{
dependencies{
...kotlinx-coroutines-core-native:1.3.5
...ktor-client-ios:1.6.1
...sqldelight:native-driver:1.5.0
}
val iosArm64Main by getting{
dependsOn(iosX64Main)
}
OR
ios {
binaries{
framework{
baseName = "commonModule"
}
}
}
val iosMain by getting{
dependencies{
...kotlinx-coroutines-core-native:1.3.5
...ktor-client-ios:1.6.1
...sqldelight:native-driver:1.5.0
}
OR any structure u prefer And regardless of type u prefer, xCode everytime return error when try to build project like task embedAndSignAppleFrameworkForXcode not found OR NVActivityIndicatorView not found for target x86_64-apple-ios-simulator OR one time I saw error like DatabaseDriverFactory has no dependencies OR Execution failed for task "commonModulecompileKotlinIosX64" OR etc... So... can any1 explain me what I need to do?! I feel like a blind kitten and constantly bump into walls 🤕
🧵 2
s
What I worked out was the following. I still can’t do simulator builds because not every library we use supports the M1 simulator.
Copy code
val iosArm64 = iosArm64()
     // Uncomment this and add it to the list of iosTargets once libraries catch up and start publishing
     // binary artifacts for the ios arm64 simulator.
     //val iosArm64Sim = iosSimulatorArm64()
     val iosX64 = iosX64()
     // Uncomment and add to the list of targets below to add macosX64 targets
     //val macosX64 = macosX64() 
     val darwinTargets = listOf(iosArm64, iosX64)

     configure(darwinTargets) {
         binaries.framework {
             baseName = libName
             embedBitcode("bitcode")
             export("co.touchlab:kermit:0.1.9")
             transitiveExport = true
             xcf.add(this)
         }
     }
For sourcesets:
Copy code
val darwinMain by sourceSets.creating {
             dependsOn(commonMain)
             dependencies {
                 implementation(libs.ktor.client.ios)
                 api("co.touchlab:crashkios:${Versions.iOS.crashkios}")
             }
         }
         val iosX64Main by sourceSets.getting {
             dependsOn(darwinMain)
         }
         val iosArm64Main by sourceSets.getting {
             dependsOn(darwinMain)
         }
 // Uncomment when enabling building for macOS.
 //        val macosX64Main by sourceSets.getting {
 //            dependsOn(darwinMain)
 //        }
The original packForXcode task became much simpler, although I do want to improve it to move the framework to a common directory so that I can pull it into xcode easier.
Copy code
val packForXcode by tasks.creating(Sync::class) {
     // selecting the right configuration for the iOS
     // framework depending on the environment
     // variables set by Xcode build
     val mode = (project.findProperty("XCODE_CONFIGURATION")?.toString()?.toUpperCase()
         ?: "DEBUG").split("_").first()

     if (mode == "DEBUG"){
         dependsOn("assembleRoll20CoreDebugXCFramework")
     }else {
         dependsOn("assembleRoll20CoreReleaseXCFramework")
     }
 }