touchlab-lab / KotlinCocoapods

Apache License 2.0
75 stars 6 forks source link

Can't add pods to iosMain source set #7

Closed aiidziis closed 4 years ago

aiidziis commented 4 years ago

While using "co.touchlab.native.cocoapods" plugin in project, I tried to add AFNetworking pod for iosMain source set by doing this:

cocoapodsext {
    summary = Podspec.summary
    homepage = Podspec.homepage
    isStatic = false
    pod(name = "AFNetworking", version = "~> 4.0")
}

When run pod install and tried to rebuild project in Xcode it failed with stacktrace:

> Task :common:cinteropAFNetworkingIos FAILED
Exception in thread "main" java.lang.Error: /var/folders/tx/90l_s4xn5hz1g4q3bnq_d1400000gn/T/tmp9058487730325846355.m:1:9: fatal error: module 'AFNetworking' not found
    at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
    at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:67)
    at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:13)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:446)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:228)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:46)
    at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:44)
    at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
    at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:37)

Jetbrains documentation on this: https://kotlinlang.org/docs/reference/native/cocoapods.html#interoperability

aiidziis commented 4 years ago

Found out that it actually works, the reason why it didn't work for me at first was - after adding new pod(....) you must run gradle task which regenerates podspec after that you have to run pod install and it all gets resolved in Xcode.