https://kotlinlang.org logo
#ios
Title
# ios
a

Alexander von Below

03/20/2023, 3:03 PM
Hello, I am trying to use the CocoaMQTT Pod in the iOS Part of my App . I have created a minimal sample that exhibits the issue here: https://github.com/below/PodSample When you try to build the app for iOS, there is an error:
Copy code
> Task :shared:cinteropCocoaMQTTIosSimulatorArm64
Exception in thread "main" java.lang.Error: /Users/below/dev/kmp/PodSample/shared/build/cocoapods/synthetic/IOS/build/Release-iphonesimulator/CocoaMQTT/CocoaMQTT.framework/Headers/CocoaMQTT-Swift.h:560:58: error: cannot find protocol declaration for 'MGCDAsyncSocketDelegate'
Any idea what could be wrong? Thank you!
k

Konstantin Tskhovrebov

03/20/2023, 3:05 PM
does the library have ObjC headers? Kotlin doesn't have Swift interop
a

Alexander von Below

03/20/2023, 3:37 PM
Thank you @Konstantin Tskhovrebov. yes, it does. I have also tried it with a native Objective-C app, just to be sure
m

Michal Harakal

03/20/2023, 4:58 PM
@Konstantin Tskhovrebov for me it looks like an issue with processing of spec.dependencies. Error states that
MGCDAsyncSocketDelegate
is missing, which is part of
MqttCocoaAsyncSocket
and this is defined as spec.dependency of the library. If I define
MqttCocoaAsyncSocket
to be imported explicitly via
build.gradle.kts
file, for some reason is
cinterpro
task for
MqttCocoaAsyncSocket
called always after the main lib
CocoaMQTT
. So I am also still getting the error …
k

Konstantin Tskhovrebov

03/20/2023, 7:25 PM
@a-dd cc
a

a-dd

03/22/2023, 11:20 PM
@Alexander von Below there are
@import
directive usages in a generated Obj-C header. It is supported only since 1.8.20-RC and it requires additional cinterop flag for now:
Copy code
pod("CocoaMQTT") {
    extraOpts = listOf("-compiler-option", "-fmodules")
}
More details in https://youtrack.jetbrains.com/issue/KT-39120/Cinterop-tool-doesnt-support-the-fmodules-compiler-argument
m

Michal Harakal

03/23/2023, 4:57 PM
Thank you very much, @a-dd
20 Views