I’m having a very similar problem like the one des...
# multiplatform
k
I’m having a very similar problem like the one described above, but with the different dependency (
Ably
). My gradle sync fails on
cinterop
task (
shared:cinteropAblyIos
to be specific) with the message:
Copy code
Exception in thread "main" java.lang.Error: /var/folders/2q/gjhd6ng16j51tnmw772w02k40000gp/T/5129966869508006261.m:1:9: fatal error: could not build module 'Ably'
I tried to check whether I’m able to import some other cocoapods dependency and for example I can import
AFNetworking
and use it, but when I try to import Ably it doesn’t work What is the reason it fails? It’s something wrong with the dependency itself?
Copy code
cocoapods {
    summary = "Some description for the Shared Module"
    homepage = "Link to the Shared Module homepage"
    ios.deploymentTarget = "14.1"
    frameworkName = "shared"
    pod("Ably") {
        version = "~> 1.2"
    }
    podfile = project.file("../iosApp/Podfile")
}
x
What's your kmm version and cocoapods version?
k
I’m using Kotlin 1.5.30 and the same version for both multiplatform and cocoapods plugins
m
@KamilH put this in your
build.gradle
and see if it helps:
Copy code
extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=")
You should also probably update to Kotlin 1.5.31, there was at least one cinterop bugfix in there that I know of.
k
Thanks @matej for suggestion, but it didn’t help in my case. I updated to Kotlin 1.5.31 and tried to add the dependency like that:
Copy code
pod("Ably") {
    version = "~> 1.2"
    extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=")
}
and I’m still getting the same error. I also updated to the latest XCode (13.0, before I was on 12.5) version and still the same
m
@KamilH can you try doing it like this directly in the cocoapods block:
Copy code
cocoapods {

        tasks.withType(org.jetbrains.kotlin.gradle.tasks.CInteropProcess::class.java) {
            settings.compilerOpts("-DNS_FORMAT_ARGUMENT(A)=")
        }
    }
k
I just tried, but unfortunately it didn’t help as well
m
Sorry I couldn't help. It's probably worth for you taking a look at issues mentioning
cinterop
in Kotlin's issue tracker: https://youtrack.jetbrains.com/issues?q=project:%20Kotlin If you don't find anything that helps move forward, you can create a new issue and attach a small reproducer project. They're pretty responsive over there.
b
I was able to resolve this by also adding this to my
gradle.properties
Copy code
kotlin.mpp.enableCInteropCommonization=true
as well as the above mentioned compiler option
though it only fixed my issue because all of my iOS code is inside the iosMain directory
and I'm guessing this links the iosX64 and iosArm64 cinterops to iosMain
k
Thanks Brendan, I’m already using this settings (I’m using hierarchical project structure), but thanks for the suggestion Matej, I already posted my case here and I hope it will let Kotlin’s team identify the problem easier
x
Copy code
cocoapods {        
        pod("msgpack", "0.4.0")
        pod("AblyDeltaCodec", "1.3.1")
     // pod("Ably", "1.2.6")
}
I have try add dependencies on
msgpack
and
AblyDeltaCodec
, it is successful. but add
Ably
then got same error:`cinteropAblyIosArm64 FAILED. fatal error: could not build module 'Ably'`