https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
t

Tiago Nunes

06/16/2021, 10:22 AM
Hey everyone, I've created a KMM library (with Android and ios targets) using the cocoapods plugin. This library imports an Obj C library via pod. The library compiles, and cinteropsObjCLibraryIos task works great. Then I create another KMM project, and import the library project (in settings.gradle) and add the dependency to commonMain (
implement(project(":myLibrary"))
). When I sync and build for Android, everything works great, I even get code completion in iosMain. But when I run for iOS, I get this error:
Copy code
Task :MyLibrary:cinteropObjCLibraryIos FAILED
Exception in thread "main" java.lang.Error: /var/folders/26/l5zqw1v936l866mn2pwdy2j00000gn/T/7243334423362035241.m:1:9: fatal error: module 'ObjCLibrary' not found
Any ideas? I've been stuck for hours...
c

coolcat

07/21/2021, 8:49 PM
Did you have any progress with this?
o

Osman Saral

09/17/2021, 11:31 AM
do you have m1 mac?
t

Tiago Nunes

09/17/2021, 12:09 PM
Yes
o

Osman Saral

09/17/2021, 12:10 PM
great 🙂 did you find anything on this?
the cinterop builds success on terminal but not on xcode.
i thought this was an issue with java version but i'm not sure
t

Tiago Nunes

09/17/2021, 12:14 PM
Yes, this happened because I was running the cinterop task using an ARM JDK (OpenJDK Zulu ARM64). cinterop is not supported for M1 untill Kotlin 1.5.30
Solution: Either update to Kotlin 1.5.30 or rerun the failing tasks through Rosetta. It should cache them, and build should work 🙂
o

Osman Saral

09/17/2021, 12:15 PM
it was working before i use 1.5.30. I've update to kotlin 1.5.30 an now it doesn't 😄
t

Tiago Nunes

09/17/2021, 12:15 PM
Then maybe your problem is that you’re using an Intel JDK?
run java --version
o

Osman Saral

09/17/2021, 12:23 PM
nope 😞 openjdk 11.0.12 2021-07-20 LTS OpenJDK Runtime Environment Zulu11.50+19-CA (build 11.0.12+7-LTS) OpenJDK 64-Bit Server VM Zulu11.50+19-CA (build 11.0.12+7-LTS, mixed mode)
t

Tiago Nunes

09/17/2021, 12:24 PM
Sorry, I can’t remember exactly how we solved it :s
o

Osman Saral

09/17/2021, 12:32 PM
do you have iosSimulatorArm64 target on your build gradle?
t

Tiago Nunes

09/17/2021, 1:13 PM
I do this in my build.gradle.kts:
Copy code
val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
    if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
        ::iosArm64
    else
        ::iosX64

iosTarget("ios") {}

cocoapods {
    summary = "Some description for the Shared Module"
    homepage = "Link to the Shared Module homepage"
    ios.deploymentTarget = "14.1"
    framework {
        baseName = "shared"
    }
    podfile = project.file("../iosApp/Podfile")
}
Maybe try
iosArm64("ios")
instead?
o

Osman Saral

09/17/2021, 1:44 PM
I also have the same targets 😕
can you show me your java --version output?
I downgraded to kotlin 1.5.21. it didn't work. I upgraded again to 1.5.30. and it dit work. 🤯
t

Tiago Nunes

09/17/2021, 2:24 PM
Hm maybe try Build > Clean Project
Copy code
% java --version
openjdk 16.0.1 2021-04-20
OpenJDK Runtime Environment Zulu16.30+15-CA (build 16.0.1+9)
OpenJDK 64-Bit Server VM Zulu16.30+15-CA (build 16.0.1+9, mixed mode, sharing)
🙏 1