Hi, I have a strange issue with cocoapods integrat...
# multiplatform
i
Hi, I have a strange issue with cocoapods integration that I hope someone can give some insight into. We've been working on a kmm project and development has been going well. Now we want to set up the analytics so in the
build.gradle
cocoapods
block, we added
pods("FirebaseAnalytics")
. Adding the pod work fine and Analytics is working, but now Xcode has lost all reference to my shared project, none of the autocomplete works and it's full of errors about none of my
shared
classes are in the scope. From my investigation, after gradle runs its magic, it's supposed to generates a framework of my
shared
module at path
build/cocoapods/framework
. Inside the framework, there's supposed to be a
shared.framework/Headers/shared.h
where all the
shared
module's headers are. But the issue is that after I add the
pod()
function inside the
cocoapods
block, the framework only contains a
placeholder.h
file inside the Headers folder which is only contains this single line
Copy code
// Autogenerated placeholder header. Do not edit manually.
The strange thing is while Xcode is filled with errors, I can actually build and run the app perfectly fine. Also if I remove the
pods("FirebaseAnalytics")
, everything is back to normal,
shared.h
is back in the Headers folder instead of
placeholder.h
. Any ideas how to resolve this issue?
l
I’ve run into this issue before. The solution for me was to manually run the following command once. After this, it works fine until I run a gradle clean,
./gradlew syncFramework  -Pkotlin.native.cocoapods.platform=iphonesimulator -Pkotlin.native.cocoapods.archs=x86_64 -Pkotlin.native.cocoapods.configuration=Debug
Any configuration should work (assuming your iosArm64, iosX64, and iosSimulatorArm64 share a source set). It just needs to create the framework. It works when you build in XCode since it runs that same command in the background when you build.
i
Cheers Landry, I'll give this a try when I'm back at the office.
But I do want to enquire, does Xcode not run that command when it's during the indexing phase? I would assume it runs the gradle build commands, since
:shared:generateDummyFramework
should be what is creating the
placeholder.h
, and if I build on Android Studio, I can see the last task gradle tries to do is
:shared:syncFramework
, which it seems Xcode hasn't ran this task. If Xcode runs that command in the background when it builds, then shouldn't building the app cause
shared.h
to be created and all Xcode errors should disappear?
l
I think when I looked into it, there was something that would cause it to generate the placeholder, but I never figured out exactly what (I’m sure if it was easy, JB would have fixed this months ago). Running that exact command manually has always worked for me.