ZabGo
04/27/2020, 3:09 PMbuildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
build.gradle(module)
plugins {
kotlin("multiplatform")
}
Kotlin{
iosX64("ios"){
binaries {
framework {
baseName = "SharedCode"
}
}
}
jvm("android")
sourceSets["commonMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
implementation("io.ktor:ktor-client-core:1.3.2")
implementation("io.ktor:ktor-client-json:1.3.2")
implementation("io.ktor:ktor-client-serialization:1.3.2")
}
sourceSets["androidMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("io.ktor:ktor-client-android:1.3.2")
}
sourceSets["iosMain"].dependencies{
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("io.ktor:ktor-client-ios:1.3.2")
implementation("io.ktor:ktor-client-json-native:1.3.2")
implementation("io.ktor:ktor-client-serialization-native:1.3.2")
}
}Patrick
04/27/2020, 3:22 PMZabGo
04/27/2020, 3:26 PMactual fun platformName(): String {
return UIDevice.currentDevice.systemName() +
" " +
UIDevice.currentDevice.systemVersion
}
Patrick
04/28/2020, 8:45 AMZabGo
04/28/2020, 8:54 AMunresolved reference
. It's certainly a problem about how I import the dependencies. It was fine before I upgrade to 1.3.72Patrick
04/28/2020, 8:56 AMZabGo
04/28/2020, 8:57 AMZabGo
04/28/2020, 8:58 AMmagnumrocha
04/28/2020, 9:01 AMZabGo
04/28/2020, 9:05 AMmagnumrocha
04/28/2020, 9:07 AMZabGo
04/28/2020, 9:18 AMmagnumrocha
04/28/2020, 9:19 AMZabGo
04/28/2020, 9:29 AMmagnumrocha
04/28/2020, 9:31 AMmagnumrocha
04/28/2020, 9:32 AMZabGo
04/28/2020, 9:34 AMmagnumrocha
04/28/2020, 9:35 AMPatrick
04/28/2020, 9:36 AMZabGo
04/28/2020, 9:38 AMZabGo
04/28/2020, 9:55 AMmagnumrocha
04/28/2020, 10:07 AMPatrick
04/28/2020, 10:15 AMZabGo
04/28/2020, 10:18 AMmagnumrocha
04/28/2020, 10:18 AMmagnumrocha
04/28/2020, 10:19 AMPatrick
04/28/2020, 10:23 AMZabGo
04/28/2020, 10:23 AMmagnumrocha
04/28/2020, 10:29 AMUIDevice
class is from UIKit
lib, a platform native lib (from iOS SDK, not thrid-party), that should works with kotlin-native (in a MacOS env) without any other configuration, but the setup of the gradle pluginZabGo
04/28/2020, 10:39 AMPatrick
04/28/2020, 10:40 AMmagnumrocha
04/28/2020, 10:42 AMZabGo
04/28/2020, 10:42 AMmagnumrocha
04/28/2020, 10:55 AMconfigure([targets.iosX64]) {
compilations.main.source(sourceSets.iosMain)
}
magnumrocha
04/28/2020, 10:57 AMKotlin{
well, I don't know if gradle is case sensitive, but I set this always as kotlin { ... }
in lowercase....magnumrocha
04/28/2020, 10:58 AMZabGo
04/28/2020, 11:22 AMZabGo
04/28/2020, 11:23 AMLine 38: configure([targets.iosX64]) {
^ Not enough information to infer type variable T
Line 38: configure([targets.iosX64]) {
^ Type mismatch: inferred type is Array<???> but (Mutable)Iterable<(???..???)>! was expected
Line 38: configure([targets.iosX64]) {
^ Unsupported [Collection literals outside of annotations]
Line 38: configure([targets.iosX64]) {
^ Unresolved reference: iosX64
4 errors
ZabGo
04/28/2020, 11:27 AMconfigure(listOf(targets.iosX64)) {
compilations.main.source(sourceSets["iosMain"])
}
ZabGo
04/28/2020, 11:28 AM* What went wrong:
Script compilation errors:
Line 38: configure(listOf(targets.iosX64)) {
^ Unresolved reference: iosX64
Line 38: configure(listOf(targets.iosX64)) {
^ Type mismatch: inferred type is () -> [ERROR : Cannot infer type variable TypeVariable(_L)] but Closure<(raw) Any!>! was expected
Line 39: compilations.main.source(sourceSets["iosMain"])
^ Unresolved reference: compilations
3 errors
magnumrocha
04/28/2020, 11:29 AMZabGo
04/28/2020, 11:29 AMZabGo
04/28/2020, 11:29 AMZabGo
04/28/2020, 11:29 AMZabGo
04/28/2020, 11:44 AMiosX64("ios") {
binaries {
framework {
baseName = "SharedCode"
}
}
}
jvm("android")
sourceSets["commonMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
}
sourceSets["iosMain"].dependencies {
}
configure(listOf(targets["ios"])) {
compilations.getByName("main"){
source(sourceSets["iosMain"])
}
}
And I tried this:
iosX64("ios") {
binaries {
framework {
baseName = "SharedCode"
}
}
compilations.getByName("main"){
source(sourceSets["iosMain"])
}
}
jvm("android")
sourceSets["commonMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
}
sourceSets["iosMain"].dependencies {
}
But I still have the same problemmagnumrocha
04/28/2020, 1:21 PMZabGo
04/29/2020, 8:50 AMThe Kotlin/Native distribution used in this build does not provide the standard library.
but I still cannot access uikit.uidevice.
I updated xcode to xcode 11.4 (was 11.3 before), tried to use openjdk 14 instead of the embedded one and also to change the kotlin compiler to 1.3.61 but did not change anything.magnumrocha
04/29/2020, 9:08 AMmagnumrocha
04/29/2020, 9:09 AMZabGo
04/29/2020, 9:16 AMZabGo
04/29/2020, 12:53 PMPatrick
05/05/2020, 8:54 AMZabGo
05/05/2020, 12:22 PM