0

What went wrong

Environment:

System                                           
    OS: macOS (13.0.1)
    CPU: Apple M1

Java
    Java (openjdk version "11.0.16.1" 2022-08-12)
    Location: /opt/homebrew/opt/openjdk@11/bin/java
    
    JAVA_HOME=/opt/homebrew/opt/openjdk@11
    
Android Studio
    Android Studio (2021.3)
    Location: /Applications/Android Studio.app
    Bundled Java: openjdk 11.0.13 2021-10-19
    Kotlin Plugin: 213-1.7.20-release-for-android-studio-AS6777.52
    Kotlin Multiplatform Mobile Plugin: 0.3.4(213-1.7.11-357-IJ)-241
    
Xcode
    Xcode (14.1)
    Location: /Applications/Xcode.app
    

build.gradle.kts for shared (only kotlin block):

kotlin {
    android()

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

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(project(SharedModule.networkMock))
                implementation(project(SharedModule.storage))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation(Dependencies.hiltAndroid)
                implementation(Dependencies.okHttp)
                configurations.kaptHilt()
            }
        }
        val iosArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosArm64Main.dependsOn(this)
            dependencies {
                implementation(Dependencies.coroutinesNative)
            }
        }
    }
}

Didn't work for me:

  • running Xcode from Rosetta
  • excluding arm64 from architectures
  • running Xcode build with closed Android Studio and killed java processes
  • running on simulator/real device.

1 Answers1

1

The error was resolved after I used x86 JVM (Azul Zulu) and opened Xcode using Rosetta. You need to be sure that in Settings->Locations->Custom Paths you set correct JAVA_HOME folder. Hope this helps someone.