I'm trying to add a dependency on a Pod library fr...
# multiplatform
j
I'm trying to add a dependency on a Pod library from the CocoaPods repository to a KMM project, but I believe that Gradle is somehow causing my Podfile to be read improperly, almost as if the 'pod' command is ignoring it. When I attempt to sync the Gradle project, I get the following error and warning:
Copy code
Generating workspace in `shared/build/cocoapods/synthetic/IOS/shared`
[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `web3swift.pod` depends upon `secp256k1.c`, `keccak.c`, and `scrypt.c`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

[!] Automatically assigning platform `iOS` with version `13.0` on target `App-iOS` because no platform was specified. Please specify a platform for this target in your Podfile. See `<https://guides.cocoapods.org/syntax/podfile.html#platform>`.
The CocoaPods section of my build.gradle.kts file (which is located in "Project/shared") looks like this:
Copy code
version = "1.0"
ios()
cocoapods {
    summary = "A summary to make CocoaPods happy"
    homepage = "A page to make CocoaPods happy"
    ios.deploymentTarget = "13.0"
    pod("web3swift.pod") {
    }
    useLibraries()
    podfile = project.file("../iosApp/Podfile")
}
And my Podfile (which is located in "Project/iosApp") looks like:
Copy code
source '<https://cdn.cocoapods.org>'
use_modular_headers!
target 'App-iOS' do
    platform :ios, '13.0'
end
Any idea why I am still getting this error and warning, even though I have clearly implemented the fix in the Podfile? Any help is much appreciated.
When I remove only the dependency on web3swift.pod, Gradle successfully syncs.
I just tried to add a dependency on the MatrixSDK Pod and received the same platform specification error.
m
https://github.com/skywinder/web3swift#installation Did you try without the
use_modular_headers
and instead use the
use_frameworks!
under the target in which you consume the pod?
As per the above link, there’s no sign of
use_modular_headers
j
Yes, I tried using
use_frameworks!
in place of
use_modular_headers!
. I also tried them both together, since the first error message says I need to enable modular headers. I continue to get the same error and warning.
m
Right, can’t help you out any further then. I use the pods as I’d use in a normal iOS project (run separate pod install) and it works just fine E: didn’t try with your pod, just in general
j
Also, I'm using https://github.com/BANKEX/web3swift instead of sky winder's web3swift, as the latter doesn't yet support Objective-C.
i
@jimmyt This seems the same issue as described here. https://kotlinlang.slack.com/archives/C3PQML5NU/p1634561361116100
j
@Igor Maric Thanks, but I believe this is a different issue. All those issues seem to relate to the C compiler included in Xcode 13 not cooperating with KMM. I'm still running Xcode 12.5, which is what they recommend downgrading to in those issues, and my problems all seem to relate to Gradle somehow not properly reading my Podfile when it executes "pod" commands. This is the error that Gradle gives me when syncing:
Copy code
Executing of 'pod gen --use-libraries --platforms=ios --gen-directory=/Users/username/Project/shared/build/cocoapods/synthetic/IOS --sources=<https://cdn.cocoapods.org> /Users/username/Project/shared/shared.podspec' failed with code 1 and message: 


[!] Automatically assigning platform `iOS` with version `13.0` on target `App-iOS` because no platform was specified. Please specify a platform for this target in your Podfile. See `<https://guides.cocoapods.org/syntax/podfile.html#platform>`.
As you can see, I have clearly implemented the fix for this issue in my Podfile and included a reference to the Podfile in
build.gradle.kts
, but I continue to get this warning.
Alright, I sort of got it working. I modified the command that Gradle kept failing on to include the following options:
--use-podfile --podfile-path=/Users/username/Project/iosApp/Podfile
and I also updated that Podfile to implement the fix for the modular-headers-related error in my original post:
Copy code
source '<https://cdn.cocoapods.org>'
target 'App-iOS' do
    pod 'web3swift.pod'
    use_frameworks!
    use_modular_headers!
    platform :ios, '13.0'
end
When I run the modified "pod gen" command, instead of the error and warning in my original post, I get: `Generating workspace in `shared/build/cocoapods/synthetic/IOS/shared`` `Open
shared/build/cocoapods/synthetic/IOS/shared/shared.xcworkspace
to work on it!` So my hunch was correct: Gradle isn't properly passing the Podfile to the "pod" command. Is there something I can do to correct this?
I moved my Podfile to the /Project directory, adjusted my build.gradle.kts file to point to it, and tried to sync again, and the podGen task worked fine, but I got a new error in the "sharedpodBuildWeb3swift.podIphonesimulator" task. Now, no matter where tell Gradle to look for the Podfile or whether or not the Podfile is correct, the podGen task works perfectly and the process crashes during that "podBuildWeb3swift.pod" task.
Added a dependency on the MatrixSDK Pod and now podGen is no longer working, and is failing with the same "Automatically assigning platform..." error. Confusing...
244 Views