<@UC44UESH4> I'm integrating moko-kswift into my p...
# moko
s
@alex009 I'm integrating moko-kswift into my project. The manual addition of the generation swift file into XCode works. However I'm trying to integrate it using cocoapods. I ran the gradle task that generates the podspec file and it did. However, the MultiPlatformLibrarySwift folder isn't getting created under cocoapods directory where the podspec expects (_spec.source_files = "build/cocoapods/framework/MultiPlatformLibrarySwift/**/*.{h,m,swift}"_). How would I get it to generate in that path?
I tried the sample project here: https://github.com/Alex009/moko-kswift-usage-sample/tree/cocoapods And the same issue occurs. The XXXXSwift folder gets generated in the target directory (build/bin/{iosArm64 || iosX64}/{debugFramework || releaseFramework}/{frameworkName}Swift) but not in the cocoapods directory. Hence I'm unable to import MultiPlatformLibrarySwift from XCode.
a
hi. in past kotlin cocoapods plugin do copy of all content in
build/bin/arch/buildTypeFramework
but now copy only *.framework directory. So to fix it please add in gradle config:
Copy code
tasks.matching { it.name == "syncFramework" }.configureEach {
    doLast {
        val linkTasks: List<KotlinNativeLink> = this.dependsOn.filterIsInstance<TaskProvider<*>>()
            .map { it.get() }
            .filterIsInstance<KotlinNativeLink>()

        val linkTask: KotlinNativeLink = linkTasks.first()
        val genDir = File(linkTask.outputFile.get().parentFile, "MultiPlatformLibrarySwift")
        genDir.copyRecursively(
            File(buildDir, "cocoapods/framework/MultiPlatformLibrarySwift"),
            overwrite = true
        )
    }
}
then do build in xcode, cocoapods will run framework compilation, kswift generate sources, then do pod install again to cocoapods see generated sources. after it just run app
s
@alex009 Thanks. Tried this, the copy to cocoapods directory worked correctly however when I did pod install and then did a run in XCode, the generated swift code (from 3rd party libraries and an internal KMM module thats a dependency to the one exposed to iOS) is full of errors. Most of them "Cannot find type XXXX in scope", "No type XXXX in module MultiPlatformLibrary". What am I missing?
a
you can filter what libs should be processed by kswift. for example - https://gitlab.icerockdev.com/scl/boilerplate/mobile-moko-boilerplate/-/blob/master/mpp-library/build.gradle.kts#L116 or by includeLibrary (to fill whitelist)
s
Thanks, I have resolved it by copying only the file I was interested to the cocoapods directory.