Hello everyone, any iOS expert that can help me wi...
# multiplatform
e
Hello everyone, any iOS expert that can help me with a Framework not found issue when using the cocoapods block? It was working for me previously (not sure what changed since then). Here's the report in YouTrack: https://youtrack.jetbrains.com/issue/KT-66490/Framework-GoogleSignIn-Not-Found-when-using-cocoapods-block
f
I also faced same issue while installing Firebase via
native-cocoapods
end up installing via swift-pk-manager
e
Is there a way to use in the iOS compose module a library installed via swift pkg manager?
j
You need to link to the framework binary in your main umbrella framework. Since you moved
GoogleSignIn
to another module, it's no longer linking in the main
composeApp
module. You can add:
Copy code
cocoapods {
    pod("GoogleSignIn", linkOnly = true)
}
to the
composeApp
build.gradle.kts to have it added to the .podspec without generating C interop in that module.
e
@Jeff Lockhart I rolled back to a previous state which was working before I modularized it and it’s still not able to find it. Also if I create a project from scratch using the JetBrains Wizard, just by adding the cocoapod block with GoogleSignIn it fails (check the single module branch in the you track report). Any clue what can be corrupted? What I tried: • Clean and Rebuild in both XCode and Android Studio • Pod Deintegrate and Pod Install after gradle sync • Clean XCode Derived Data • Reset XCode using a command I found in the internet • Reinstalling XCode • Play with the framework search paths Can you by any chance try my single module branch and see if it builds for you?
j
Make sure the iOS app is using CocoaPods to integrate the shared Kotlin module. You should be opening the .xcworkspace not .xcproject in Xcode as well.
e
Forgot to mention about that. I edited the run configuration in Android Studio to make sure the .xcworkspace is selected and when opening the iosApp always open the .xcworkspace
Not sure if that’s enough and also not sure what you mean by having cocoapods integrate the shared kotlin module, how’s that done?
j
Did you generate the project to use CocoaPods to install the Kotlin shared framework using the Android Studio KMM plugin? The template at kmp.jetbrains.com doesn't provide this option.
e
I’m not an expert in this subject. I’ll try to describe what I did: I create a CMP project using the wizard. Then proceed to add the native cocoapods plugin and the cocoapods block. Is this enough, or should I been doing something else to make sure the project is using cocoapods to install the Kotlin shared framework?
j
create a CMP project using the wizard
Was that kmp.jetbrains.com wizard or the KMM plugin in Android Studio?
e
j
Unfortunately the kmp.jetbrains.com template doesn't give you the option to use the CocoaPods plugin for the shared module framework. So the iosApp that's generated doesn't use the generated .podspec to link to your shared Kotlin library. I pointed out the gap in the documentation and lack of this functionality here.
You can migrate your iosApp Xcode project to use CocoaPods. It may be easier just to generate it with the KMM plugin though, as it gives you the option. You could even just use the iosApp generated by the KMM plugin and replace the iosApp generated by the kmp.jetbrains.com template.
If you compare the projects generated both ways, you can see the important differences with how the shared Kotlin framework is linked in the iOS app.
e
To confirm I understood you correctly. You mean that the CMP project generated by Android Studio, comes with the right cocoapods integration? Would you recommend I use Fleet to create the project instead or it doesn’t really make a difference?
I think this is what you mean
j
Fleet doesn't have a built-in KMP wizard. It relies on kmp.jetbrains.com. The Kotlin Multiplatform Mobile plugin for Android Studio does have its own wizard though. It's not as up-to-date as the kmp.jetbrains.com template, and doesn't generate a Compose Multiplatform project. But it does have the option to generate a KMP app and gives you the option to use "regular framework" or "CocoaPods dependency manager". kmp.jetbrains.com projects are generated similar to "regular framework". This is why I suggested you might merge the two templates. Take the iosApp from the KMM plugin project and replace the kmp.jetbrains.com app with this Xcode iOS app project, which integrates the Kotlin shared module framework using CocoaPods.
I think this is what you mean
Yes
I've got a bare-bones sample app for my library that uses both Compose Multiplatform and CocoaPods. You could use that as a starting point as well.
e
Thank you 🙏🏼 I will try the AS plugin and your sample to see how it goes, i’ll be back
@Jeff Lockhart It worked just by creating the project using AS and choosing cocoapods. I can’t believe i wasted so much time trying to solve this. Thank you so much! Tomorrow I’ll try extracting it to a separate module, will see how it goes. Any insight on using the cocoapods block on multiple modules on the same project?
j
You should be able to use the cocoapods block in multiple modules. It will create a .podspec file for each module, unless you specify
noPodspec()
in the config. You should only need the .podspec for the umbrella module used directly by the iOS app. But you will need to specify any pod dependencies used in other dependency modules in that umbrella module explicitly, as Kotlin Gradle modules don't propagate these CocoaPods dependencies automatically. As I mentioned above, you can use the
linkOnly = true
option in the umbrella framework to avoid generating unnecessary C interop, if all you need to do is link the framework.