Do the IDE code references between Kotlin and Swif...
# multiplatform
l
Do the IDE code references between Kotlin and Swift work for anyone who uses AppCode with KMM? For me, objects from the shared Kotlin library in Swift code are red underlined, even the new KMM project template is broken for me.
👀 1
v
Works just fine. With one project’s setup - I get directed directly to the
.kt
files reference to the specific location. With another I get a massive
.swift
file mapping generated which does not directly jump to the
.kt
file. (Not sure why though) - So, something’s up with how you’ve set up the project probably. (Also try Gradle -> Reload All Gradle Projects)
l
This is a new KMM project I have so far ignored the
Collection contains no element matching the predicate.
error, but that might be a problem 😄
v
How does your build.gradle look?
l
Android
Copy code
plugins {
    kotlin("multiplatform")
    id("com.android.application")
}

group = "me.user"
version = "1.0-SNAPSHOT"

repositories {
    google()
    jcenter()
}

kotlin {
    android()
    sourceSets {
        val androidMain by getting {
            dependencies {
                implementation(project(":shared"))
                implementation("com.google.android.material:material:1.5.0")
                implementation("androidx.appcompat:appcompat:1.4.1")
                implementation("androidx.constraintlayout:constraintlayout:2.1.3")
            }
        }
    }
}

android {
    compileSdkVersion(31)
    defaultConfig {
        applicationId = "me.user.androidApp"
        minSdkVersion(24)
        targetSdkVersion(31)
        versionCode = 1
        versionName = "1.0"
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    buildTypes {
        getByName("release") {
            isMinifyEnabled = false
        }
    }
}
v
Wait, why’s there a build.gradle.kts under
iosApp
?
iosApp
should not need any build.gradle 🤔
l
I think it's the new KMM xcode-less iOS modules that manages the xcode project
v
Everything should be set up under the
shared/build.gradle.kts
, should look something like:
Copy code
kotlin {
    android()

    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "shared"
            isStatic = false
        }
    }

    sourceSets {
     ...
    }
}
l
That's there.. I have also tried new KMM project template with Xcode and also the KMM template from latest Android Studio. All fail the Gradle sync in AppCode with
Collection contains no element matching the predicate.
I guess I'll create an issue on YouTrack
v
Mmm, I see, this is built via
New Project -> Kotlin Multiplatform Mobile: Gradle
, I created a new project using this on my machine and actually… It works just fine 🤔 AppCode 2022.2.5, Kotlin Multiplatform Mobile for AppCode Plugin used to generate the project 222.4459.24
Just now I managed to get it running on a simulator
l
do you have M1? what's your Java version?
v
Naa, not an M1. Maybe that’s an issue.
java version “11.0.12” 2021-07-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)
And the references are working
l
I have tried AppCode 2022.2.5 with the same result. I envy you 😄 I have to switch to Xcode all the time when I want to work with the shared library 😬
c
yeah have the same issue. Not able to use app code as get unresolved references too, so I just stick with X-Code these days
l
Oh no... F
m
Yea, I understand the decision but it still feels sad to be stuck with Xcode
c
yeah thats a bit disappointing! X-Code is such a pain to work with 😢
l
inb4 the Swift plugin is moved to Android Studio and it gets renamed to Mobile Studio 😄
UPDATE: If anyone has the same problem with KMM references in AppCode, install JDK 11 🙂