I have an issue where im trying to import in Flipp...
# ios
a
I have an issue where im trying to import in FlipperKit,
Copy code
cocoapods {
        ios.deploymentTarget = "10.0"
        noPodspec()
        framework { isStatic = true }
        pod("FlipperKit")
    }
Copy code
Executing of 'pod install' failed with code 1 and message: 

Analyzing dependencies
Downloading dependencies
[!] The 'Pods-ios' target has transitive dependencies that include statically linked binaries: (Flipper-Boost-iOSX)
When i do pod install manually in the build folder, if i add use_modular_headers! it seems to download. How can i make my build gradle do this, - this is a KMM library not an app
a
Right there is no such option. But the good news is that such option will be in 1.9.0: https://youtrack.jetbrains.com/issue/KT-54161/Support-adding-extra-code-to-generated-Podfile-from-the-Kotlin-gradle-plugin
a
sweet
thanks for the update
@a-dd - so i managed to edit the podfile but for some reason the bindings are not being generated. My repo is open source using branch cocoapods-import: https://github.com/MyUNiDAYS/Klipper/tree/cocoapods-import I can see the pods in the synthetic folder, but the classes/kotlin folder is empty, just has folders in it. It actually says it cannot find the module, which is even more confusing. fatal error: module ‘FlipperKit’ not found
i see that in the pods folder, FlipperKit has a folder called iOS, should i make the moduleName be iOS? i tried this and i get a different error kotlin/iosArm64/main/cinterop/klipper-cinterop-iOS.klib does not exist
a
Hi @Andrew Reed, this should work: https://github.com/MyUNiDAYS/Klipper/pull/1 Explanation:
module
from the error message is referring to the clang modules https://clang.llvm.org/docs/Modules.html#module-map-language which usually are distributed in the form of frameworks in the apple world. Cocoapods plugin by default tries to find the framework among the pod build output but since you’ve changed cocoapods mode to the
modular headers
there are only static libraries. And that’s why it’s required to list all the public headers explicitly. Also Flipper headers are protected by
#ifdef FB_SONARKIT_ENABLED
so cinterop wasn’t able to parse the headers without the flag.
Please note that this works for now but it’s not guaranteed that this won’t break in the future (because of the Podfile patching) 🙏
a
ok cheers, will check later
works a treat, many thanks @a-dd good spot with the ifdef
Sorry @a-dd - is there any guide on how to debug when importing cocoapods? I dont want to have to keep reaching out for help but again another more tricky scenario when importing FlipperKit/SKIOSNetworkPlugin https://github.com/MyUNiDAYS/Klipper/tree/cocoapods-import I updated the build gradle to contain:
Copy code
pod("FlipperKit/SKIOSNetworkPlugin") {
    source = git("<https://github.com/Reedyuk/flipper.git>") {
        branch = "kmm"
    }
    headers = "SKIOSNetworkAdapter.h"
    extraOpts = listOf("-compiler-option", "-DFB_SONARKIT_ENABLED=1")
}
but doesnt seem to import in, not sure why. I cannot see this file anywhere in the build folder.
a
@Andrew Reed I think there’s no such guide. Our docs aren’t really comprehensive for this case 😞 But I can give you some rough directions: 1) You can look for cinterop klibs in the External Libraries section on the sidebar 2) These cinterops also should be present in the project structure window (only in IDEA, AS window is a bit different) 3) You can also ran corresponding cinterop gradle task with the
--info
flag. Like this
Run anything
->
gradle :klipper:cinteropFlipperKitIosArm64 --info --rerun
. It should give you some info about binaries and headers search paths
Screenshot 2023-05-24 at 19.42.28.png
Regarding your issue with SKIOSNetworkPlugin I guess the reason is that you forgot to update Podfile you’re rewriting simple smile
I’d recommend actually to refactor a complete rewriting to a specific fragment patching. Smth like
podfile.get().apply { writeText(readText().replace("use_frameworks!", "use_modular_headers!")) }
a
argh that makes total sense
so i made those changes (and comitted to that branch)but the commonizer is not pulling in the changes. How does it work in regards to the folders for pods, so for example the FlipperKitNetworkPlugin lives in a folder called Plugins, and i can see this in the build/cocoapods/synthetic/ios/Pods// But it doesn’t show in the commonizer, which means it must be being ignored. What sort of import would it have? cocoapods.FlipperKit.plugins.FlipperKitNetworkPlugin?
a
You can look in the contents of knm files. There will be pseudo-Kotlin code.
Do commonizer and cinterops tasks finish without warnings or errors?
a
Yes finishes without errors
I don’t recall seeing any warning either
Copy code
18:08:46: Executing 'assemble'...


> Configure project :klipper
w: Please use `androidTarget` function instead of `android` to configure android target inside `kotlin { }` block.
See the details here: <https://kotl.in/android-target-dsl>

> Task :klipper:generateDefFlipperKit
> Task :klipper:podspec SKIPPED
> Task :klipper:podGenIos
> Task :klipper:podInstallSyntheticIos
> Task :klipper:podSetupBuildFlipperKitIphoneos
> Task :klipper:podBuildFlipperKitIphoneos
> Task :klipper:cinteropFlipperKitIosArm64
> Task :klipper:podSetupBuildFlipperKitIphonesimulator
> Task :klipper:podBuildFlipperKitIphonesimulator
> Task :klipper:cinteropFlipperKitIosSimulatorArm64
> Task :klipper:cinteropFlipperKitIosX64
> Task :klipper:transformCommonMainDependenciesMetadata
> Task :klipper:generateProjectStructureMetadata
> Task :klipper:metadataCommonMainProcessResources NO-SOURCE
> Task :klipper:preBuild UP-TO-DATE
> Task :klipper:preDebugBuild UP-TO-DATE
> Task :klipper:compileDebugAidl NO-SOURCE
> Task :klipper:mergeDebugJniLibFolders
> Task :klipper:mergeDebugNativeLibs NO-SOURCE
> Task :klipper:stripDebugDebugSymbols NO-SOURCE
> Task :klipper:compileDebugRenderscript NO-SOURCE
> Task :klipper:copyDebugJniLibsProjectAndLocalJars
> Task :klipper:generateDebugBuildConfig
> Task :klipper:generateDebugResValues
> Task :klipper:generateDebugResources
> Task :klipper:packageDebugResources
> Task :klipper:parseDebugLocalResources
> Task :klipper:javaPreCompileDebug
> Task :klipper:mergeDebugShaders
> Task :klipper:compileDebugShaders NO-SOURCE
> Task :klipper:generateDebugAssets UP-TO-DATE
> Task :klipper:packageDebugAssets
> Task :klipper:packageDebugRenderscript NO-SOURCE
> Task :klipper:prepareDebugArtProfile UP-TO-DATE
> Task :klipper:prepareLintJarForPublish UP-TO-DATE
> Task :klipper:processDebugJavaRes NO-SOURCE
> Task :klipper:preReleaseBuild UP-TO-DATE
> Task :klipper:compileReleaseAidl NO-SOURCE
> Task :klipper:writeDebugAarMetadata
> Task :klipper:mergeReleaseJniLibFolders
> Task :klipper:mergeReleaseNativeLibs NO-SOURCE
> Task :klipper:stripReleaseDebugSymbols NO-SOURCE
> Task :klipper:compileReleaseRenderscript NO-SOURCE
> Task :klipper:copyReleaseJniLibsProjectAndLocalJars
> Task :klipper:generateReleaseBuildConfig
> Task :klipper:generateReleaseResValues
> Task :klipper:generateReleaseResources
> Task :klipper:packageReleaseResources
> Task :klipper:javaPreCompileRelease
> Task :klipper:parseReleaseLocalResources
> Task :klipper:mergeReleaseShaders
> Task :klipper:compileReleaseShaders NO-SOURCE
> Task :klipper:generateReleaseAssets UP-TO-DATE
> Task :klipper:packageReleaseAssets
> Task :klipper:packageReleaseRenderscript NO-SOURCE
> Task :klipper:prepareReleaseArtProfile UP-TO-DATE
> Task :klipper:processReleaseJavaRes NO-SOURCE
> Task :klipper:writeReleaseAarMetadata
> Task :klipper:processDebugManifest
> Task :klipper:processReleaseManifest
> Task :klipper:mergeReleaseResources
> Task :klipper:generateDebugRFile
> Task :klipper:generateReleaseRFile
> Task :klipper:compileKotlinIosArm64
> Task :klipper:verifyReleaseResources
> Task :klipper:compileKotlinIosSimulatorArm64
> Task :klipper:compileCommonMainKotlinMetadata

> Task :klipper:compileDebugKotlinAndroid
'compileDebugJavaWithJavac' task (current target is 11) and 'compileDebugKotlinAndroid' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
By default will become an error since Gradle 8.0+! Read more: <https://kotl.in/gradle/jvm/target-validation>
Consider using JVM toolchain: <https://kotl.in/gradle/jvm/toolchain>


> Task :klipper:compileKotlinIosX64
> Task :klipper:metadataCommonMainClasses
> Task :klipper:allMetadataJar
> Task :commonizeNativeDistribution UP-TO-DATE

> Task :klipper:compileReleaseKotlinAndroid
'compileReleaseJavaWithJavac' task (current target is 11) and 'compileReleaseKotlinAndroid' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
By default will become an error since Gradle 8.0+! Read more: <https://kotl.in/gradle/jvm/target-validation>
Consider using JVM toolchain: <https://kotl.in/gradle/jvm/toolchain>


> Task :klipper:transformIosMainCInteropDependenciesMetadata
> Task :klipper:commonizeCInterop
> Task :klipper:extractDebugAnnotations
> Task :klipper:compileDebugJavaWithJavac
> Task :klipper:mergeDebugGeneratedProguardFiles UP-TO-DATE
> Task :klipper:mergeDebugConsumerProguardFiles UP-TO-DATE
> Task :klipper:compileDebugSources
> Task :klipper:extractReleaseAnnotations
> Task :klipper:compileReleaseJavaWithJavac
> Task :klipper:mergeReleaseGeneratedProguardFiles UP-TO-DATE
> Task :klipper:mergeReleaseConsumerProguardFiles UP-TO-DATE
> Task :klipper:mergeDebugJavaResource
> Task :klipper:mergeReleaseJavaResource
> Task :klipper:syncDebugLibJars
> Task :klipper:bundleDebugAar
> Task :klipper:assembleDebug
> Task :klipper:syncReleaseLibJars
> Task :klipper:bundleReleaseAar
> Task :klipper:compileReleaseSources
> Task :klipper:assembleRelease
> Task :klipper:transformIosMainDependenciesMetadata
> Task :klipper:compileIosMainKotlinMetadata
> Task :klipper:metadataIosMainProcessResources NO-SOURCE
> Task :klipper:metadataIosMainClasses
> Task :klipper:iosArm64MetadataJar
> Task :klipper:iosSimulatorArm64MetadataJar
> Task :klipper:iosX64MetadataJar
> Task :klipper:linkPodDebugFrameworkIosArm64
> Task :klipper:linkPodDebugFrameworkIosX64
> Task :klipper:linkPodDebugFrameworkIosFat
> Task :klipper:linkPodDebugFrameworkIosSimulatorArm64
> Task :klipper:linkPodReleaseFrameworkIosArm64
> Task :klipper:linkPodReleaseFrameworkIosX64
> Task :klipper:linkPodReleaseFrameworkIosFat
> Task :klipper:linkPodReleaseFrameworkIosSimulatorArm64
> Task :klipper:assemble

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See <https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings>

BUILD SUCCESSFUL in 2m 28s
78 actionable tasks: 70 executed, 8 up-to-date
18:11:15: Execution finished 'assemble'.
@a-dd - i cant seem to put my finger on why its not importing the network plugin from cocopaods into the commonizer. It seems like it should do.
a
Do you have a commit that I could look into?
this has the latest progress to the issue im getting
a
Hmm I’ve managed to get it working: https://github.com/MyUNiDAYS/Klipper/pull/2/files. But it’s a little hacky
a
so you are importing in the headers with FlipperKit pod, and then just include the pod with header property
i guess this scenario is a little more complicated than the average cocoapod
a
The problem is that for subspecs only first pod configuration matters (for cinterop). Because there is no separate cinterop processes for each subspec. I think it deserve an issue actually. Because without knowledge of cocoapods plugin internals it’s almost impossible to set up. Could you create one here https://kotl.in/issue?
a
sure, the least i can do
358 Views