Can you add iOS libraries without cocoapods? I'm u...
# multiplatform
i
Can you add iOS libraries without cocoapods? I'm using lottie-ios in my library, and whenever you want to use that library, you have to add pods again in order for the library to work because you will keep receiving linker errors.
a
Yeah you can add them in Swift Package Manager
j
You can link to the native framework without CocoaPods, but I've found using the Kotlin CocoaPods plugin is easier than manually linking. You could also add the framework with SPM, if the native library supports it. In my library's case, only the Swift framework supports SPM, not the Objective-C framework.
I have an example in my library of manually linking to the framework locally vs using CocoaPods. Ideally, you'd probably also want to be downloading the framework instead of storing it in your repository as well, which would be an additional Gradle task.
i
I will check that out, thanks!.
the problem is that whoever wants to use my library (which uses lottie-ios)
Copy code
implementation("io.github.ismai117:kottie:latest_version")
they also have to add that pod again which can cause issues, I want them to add the library and carry on with their project without adding pods again
j
Exactly. It's the same requirement when using my library for native targets, which is why I asked about support for the CocoaPods plugin in the KMP project templates earlier today.
👍 1
Note, you don't actually need to generate the C interop again for your native framework. You should be able to add the
linkOnly = true
option to the
pod
declaration in consuming apps.
i
oh ok, I will test that out. thanks again!
👍🏼 1
👍 1
I no longer use cocoapods in my Kottie library. I downloaded the source code for Lottie, linked it, and created an interop for it.  Whoever wants to use it just needs to add the Lottie SPM package URL in Xcode. It is so much easier than having to go through the trouble of adding the CocoaPods plugin.
a
Amazing! This is good news. I did have to use another lib that uses skottie because I need the transparent background. Perhaps have a variant so people can choose?
i
Copy code
KottieAnimation(
    composition = composition,
    progress = { animationState.progress },
    modifier = modifier.size(300.dp),
    backgroundColor = MaterialTheme.colorSchema.background
)
You can add any color you want to match the container background color, so the animation is transparent for iOS. Do you think there's an easier way?
a
I this case the background is dynamic
👍 1
Not a solid color