Hey folks, I am trying to use `native.cocoa` plugin as described here: <https://kotlinlang.org/docs/...
h
Hey folks, I am trying to use
native.cocoa
plugin as described here: https://kotlinlang.org/docs/native-cocoapods.html#install-the-cocoapods-dependency-manager-and-plugin I’m just trying the code snipped from the docs to use
AFNetworking
inside iOSMain (as described in the docs).
Copy code
kotlin {
   ...
    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "14.1"
        frameworkName = "sharedClient"
        podfile = project.file("../iosClient/Podfile")

        pod("AFNetworking") {
            version = "~> 4.0.1"
        }
    }
    ...
}
The problem I am facing right now is that
cinteropAFNetworkingIos
fails:
> Task sharedClientcinteropAFNetworkingIos Exception in thread “main” java.lang.Error: /var/folders/n9/5pkml05d7mn3xzdyty8cx5380000gn/T/3707914287112298431.m19: fatal error: could not build module ‘AFNetworking’
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:192)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:68)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:14)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:531)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:268)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:76)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:38)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:60)
> Task sharedClientcinteropAFNetworkingIos FAILED
I think it is more of a cocoa pods issue on my local machine, but I don’t really know how cocoa pods works exactly under the hood. I think cocoa pods did not download AFNetworking. (In a plain iOS / xcode project (not kotlin multiplatform app) I have used successfully cocoa pods, so I think it is fair to assume the required cocoa pods gems are installed on my machine.) Could anyone please point me in the right direction?
j
Make sure you have the
cocoapods-generate
gem installed. This isn't normally required for using CocoaPods with a non-KMM iOS app. I've seen a similar error before where both
cocoapods
and
cocoapods-generate
were installed. After uninstalling and reinstalling them both it fixed the issue. Note,
frameworkName
is deprecated. You should replace it with:
Copy code
framework {
    baseName = "sharedClient"
}
h
Thanks for your answer. I have
cocoapods-generate
installed. I also tried to
sudo gem uninstall ...
both gems and reinstall them, but didnt help 😞
ok, looks like with kotlin 1.6.0 it works but with kotlin 1.5.x it doesnt … I don’t want to use 1.6.0 yet because of the recently discovered issues, I guess I will wait for 1.6.10
v
This is probably because of Xcode 13, which is fully supported in 1.6.0 only. if you’d like to stay on 1.5.3 for a while then downgrade Xcode to 12.5 as well
j
You can also get Xcode 13 working with Kotlin 1.5.31 by adding this to your build.gradle.kts:
Copy code
tasks.withType(org.jetbrains.kotlin.gradle.tasks.CInteropProcess::class.java) {
    settings.compilerOpts("-DNS_FORMAT_ARGUMENT(A)=")
}
v
Yeah, right, this is also an option