Benjamin Schlie
06/02/2025, 9:16 AM@objc
annotations.
2. Add this CocoaPod as a dependency in my KMP library using pod("MyLib")
.
3. Make my application depend on this library.
composeApp
├── src
│ └── commonMain <- Use MyLibrary
└── build.gradle.kts <- implementation(projects.libraries.MyLibrary)
iosApp
└── Podfile <- I need to add "IosLibrary" here
libraries
└── MyLibrary
├── IosLibrary <- Native CocoaPod library
│ └── IosLibrary.podspec
├── src
│ ├── commonMain
│ ├── iosMain <- "import cocoapod.IosLibrary"
│ └── jvmMain
└── build.gradle.kts <- pod("IosLibrary") with "source"
Benefits
I can open the iOS library in Xcode for development with code completion and test with an example project. And then use it directly in my KMP project. Later I expect the libraries can be moved to maven and cocoapod repositories.
Concerns
I managed to make it work, but I’m unsure if this is a viable solution. Two things I don’t like about this solution
1. I need to duplicate the pod("IosLibrary")
declaration in composeApp/build.gradle.kts
. If omitted, I encounter the error: "id: framework ‘IosLibrary’ not found" when running from xcode.
2. I have to add my IosLibrary
to iosApp/Podfile
, otherwise i get the error pod install error: “Please, check that each target depended on ComposeApp contains following dependencies:
pod 'IosSocketIoLibrary', :path =>..”
Are there any ways to get around these? I suspect that 2) is caused by the library being local, but can I solve this by export? Or is there a general better (and easier) way to integrate native libraries I should look into?
I have no prior experience with iOS development and CocoaPods.
An (incomplete) demo: https://github.com/bschlie/cocoapodlibdemotapchicoma
06/02/2025, 3:41 PMAndrey Yastrebov
06/03/2025, 3:46 PMBenjamin Schlie
06/04/2025, 7:05 AMcomposeApp
and Podfile
are necessary and not due to any misconfiguration.
Thanks for the confirmation and samples, Andrey!