and cocoapods 1.10.0). I've created a brand new project using the KMM project template. Next I've added
to the plugins block in my build.gradle.kts file in the shared module.gotcha #1: The guide includes a version for the plugin, but in practice this causes a build error
Plugin request for plugin already on the classpath must not include a version
. I'm assuming the inclusion of the
in the classpath in the project's build.gradle.kts is somehow declaring the version of the native.cocoapods plugin as well.At this point the next step is to use the cocoapods extension in the kotlin block in the shared module's build.gradle.kts. So I've added:
summary ="Some description for a Kotlin/Native module"
homepage ="Link to a Kotlin/Native module homepage"
These values will be used in the generated podspec file.gotcha #2: A this point the project will fail to build again with the error:
Cannot create binary debugFramework: binary with such a name already exists
pointing to the line where we try to configure the output framework within the ios block. Presumably the cocoapods plugin is trying to do this, so we shouldn't do it twice. Here I'm replacing:
At this point the guide says to "Re-import the project". I don't actually know what they mean by this. There does seem to be a process where you can close the AS project, delete the .idea folder and then import the project into AS again, but this doesn't seem to help.So far the iOS app will build and run, but we haven't added or used any external cocoapod dependencies. So to test this out I added
pod("AFNetworking", "~> 4.0.0")
to the cocoapods block.gotcha #3: Here, the build error is actually pretty clear
Specs satisfying the AFNetworking (~> 4.0.0) dependency were found, but they required a higher minimum deployment target.
and it suggests adding
ios.deploymentTarget = "..."
. So if we add
ios.deploymentTarget = "9.0"
(the minimum version required by AFNetworking 4.0.0, it will build)But this is where I hit a brick wall. The guide says you can now use external cocoapod dependencies with an import statement like
, but if I include this in Platform.kt in the iosMain directory, the IDE doesn't recognize it, giving the error
That too is an unresolved reference, and trying to run the app from the IDE fails with:
Undefined symbols for architecture x86_64:
"_AFNetworkingReachabilityNotificationStatusItem", referenced from:
_cocoapods_AFNetworking_AFNetworkingReachabilityNotificationStatusItem_getter_wrapper12 in shared(result.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)