Hey morning, Does someone have a good recommendati...
# multiplatform
m
Hey morning, Does someone have a good recommendation for a video or a blog post that does a deep dive on how to add an objective C dependency into a multi module app without using cocoapods or carthage? I’d like to be able to reuse a multiplatform module across 2 apps without having to copy the iOS implementation into the 2 apps.
f
What kind of objc do you want to import? A framework? The sources?
m
It could be either I guess? The same kind of dependency we’d use with cocoapods or carthage but we don’t want to use any of those package managers
f
So try spmforkmp
m
how does it work? I mean beyond just the documentation.
f
Just like cocoapods but using the embedded swift package manager of swift/xcode. Also, you have a bridge where you can put the code you want.
m
The bridge is the
swift
source set? i guess there are no autocompletion or compilation check, is there?
f
I’m trying to make bridge more developer friendly. You can use vscode for writing inside your bridge or create a local spm package that you add later to the plugin
The compilation check is done during the build of your project, it’s not a big issue
m
That bridge is onlyif we want to use a swift package that we want to expose through kmp by creating on objc bridge, right?
f
Yes, for example if you need to use the nfc api that can’t be done in kotlin, you can do it inside the bridge
Or use iOS dependency written in swift
The wrapper part is mandatory until swift import exist
m
So the only thing I need to wrap is the part I want to expose to KMP, right?
f
Yes, that’s it
m
But for regular objc frameworks, there’s no bridges required we can just add the dependency and it just works?
f
Yes, I think so, if you do that and it’s not working, create an issue and I will happy to help you.
Using firebase or sentry are both working great with the plugin
m
Thank you. Will look at that.
Out of curiosity how did you learn about how to configure cinterop properly so you could make that plugin? Is there any material you’d recommand?
f
Reading the documentation, experiment and a solid background in iOS development :D
m
Ahh. that helps a lot indeed
s
If you'd like an example usage, maplibre-compose uses spmforkmp (without a bridge, because MapLibre is ObjC)
m
What happens when different modules depend on the same library and are all embedded in an umbrella framework and we use
copyDependenciesToApp = true
Is the dependency duplicated?
f
copyDependenciesToApp
only copy the resources needed by the application, that’s all. It doesn’t care about the duplication. be sure to use the same version of the dependency eveywhere
juste like moko or compose resources
m
👍