Hi all, I am trying to build a kotlin multiplatform library which is using cocoapods to pull throug...
s

Sam O'Donovan

10 months ago
Hi all, I am trying to build a kotlin multiplatform library which is using cocoapods to pull through GRPCClient and Protobuf. We wanted to make this a library so we dont have to run the pod install step all the time. When we pull in the library into a parent project via commonMain.dependencies it will fail to build the iosApp unless we also include the same cocoapods block we used to generate the library.
ld: warning: Could not find or use auto-linked framework 'GRPCClient': framework 'GRPCClient' not found
ld: warning: Could not find or use auto-linked framework 'Protobuf': framework 'Protobuf' not found
ld: warning: Could not parse or use implicit file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore.tbd': cannot link directly with 'SwiftUICore' because product being built is not an allowed client of it
Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_GRPCCall2", referenced from:
       in ComposeApp[2](ComposeApp.framework.o)
  "_OBJC_CLASS_$_GRPCMutableCallOptions", referenced from:
       in ComposeApp[2](ComposeApp.framework.o)
  "_OBJC_CLASS_$_GRPCRequestOptions", referenced from:
       in ComposeApp[2](ComposeApp.framework.o)
ld: symbol(s) not found for architecture arm64
I can see in the External Libraries section that the GRPCClient and Protobuf klibs are being pulled in (though they are in separate klib files). Here is the gradle m2 folder for iosarm64
ls ~/.m2/repository/com/example/grpc-iosarm64/0.0.0-34-g08af418-SNAPSHOT         
grpc-iosarm64-0.0.0-34-g08af418-SNAPSHOT-cinterop-GRPCClient.klib
grpc-iosarm64-0.0.0-34-g08af418-SNAPSHOT-cinterop-Protobuf.klib
grpc-iosarm64-0.0.0-34-g08af418-SNAPSHOT-kotlin_resources.kotlin_resources.zip
grpc-iosarm64-0.0.0-34-g08af418-SNAPSHOT-metadata.jar
grpc-iosarm64-0.0.0-34-g08af418-SNAPSHOT-sources.jar
grpc-iosarm64-0.0.0-34-g08af418-SNAPSHOT.klib
grpc-iosarm64-0.0.0-34-g08af418-SNAPSHOT.module
grpc-iosarm64-0.0.0-34-g08af418-SNAPSHOT.pom
maven-metadata-local.xml
I was under the impression that we would be able to package up a library in such a way that we would not need to explicictly include the cocoapods dependencies seeing as the cinterop klibs are all being generated. Is there a way to statically link the cocoapods dependencies into a multiplatform library?