https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
k

kpgalligan

08/29/2019, 2:02 PM
Anybody publishing a library as a cocoapod? Wondering if there are any obvious issues. I’m aware that you can’t include multiple. This is for a client that wants to distribute their library to developers for use in native apps. Most would just be importing the framework on iOS. If somebody wanted to use it as a multiplatform library, that would be available as well.
b

basher

08/29/2019, 2:08 PM
We do it internally. If you want it to link against other pods, it's tricky (but doable). Main thing though is just ensuring you put out a fat framework with the dsym. Once you have that, it's like any other
vendored_framework
(in podspec lingo)
k

kpgalligan

08/29/2019, 2:09 PM
“If you want it to link against other pods, it’s tricky (but doable)” By that you mean if we want to have other Pods as dependencies?
b

basher

08/29/2019, 2:09 PM
Yep
k

kpgalligan

08/29/2019, 2:09 PM
Not in this case. I had to do that with firestore. It is tricky, especially with interop generation
b

basher

08/29/2019, 2:10 PM
Ah we haven't had to go that far. We just needed to be able to dynamically link custom SQLite for internal symbols
At some point, to make this viable in the CocoaPods ecosystem, someone will have to make a CocoaPods plug-in that uses gradle to pull in all of the mpp libraries you want into a single framework to avoid the single-k/n runtime problem
k

kpgalligan

08/29/2019, 2:12 PM
Luckily for us, the SDK is intentionally written to have no dependencies, so that won’t be an issue. Everything should be OK until an end client adds another Pod from kotlin
👍 1
Ah, was typing about the issues you were typing about
😂 1
It doesn’t sound like that would be too hard, except I don’t think all of the dependent library code is exposed to iOS. If you’re not using something I don’t think it winds up in the downstream package. Will need a way to explicitly include in config, or something less elegant (reference everything in a class that is never actually used. That’s what J2objc does when you don’t have
-ObjC
)
b

basher

08/29/2019, 2:17 PM
What do you mean?
You mean you want mpp libraries that it depends on to show up in the final framework header?
a

alex009

08/29/2019, 2:18 PM
you try to deploy kotlin multiplatform ios framework to cocoapods? but kotlin/native have limit in one kotlin framework in one project...so with your pod developer can't use other mpp library like their own busines logic?
b

basher

08/29/2019, 2:20 PM
You could deploy twice: once as a regular mpp artifact for those that already have a mpp setup and again as a pod for those who don't
👍 1
If you need dependencies to show up in the framework header, checkout the export option here: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html
k

kpgalligan

08/29/2019, 2:21 PM
“You mean you want mpp libraries that it depends on to show up in the final framework header?” Yeah, I was thinking you could pull in a bunch of dependencies in kotlin, then make one bigger framework. Like if vendor A and vendor B both publish KMP pods, you could instead make your own framework build referencing the kotlin/ios dependencies, and output one framework. However, need a way to tell the compiler that we want everything from those dependencies in the output.
b

basher

08/29/2019, 2:22 PM
the "Exporting dependencies in frameworks" section in that link is that
We use that to get some modularity internally
1
a

alex009

08/29/2019, 2:23 PM
also you can use
transitiveExport = true
for export all to header
k

kpgalligan

08/29/2019, 2:23 PM
Ah, yeah. That’s what I was thinking about.
b

basher

08/29/2019, 2:23 PM
Ah nice. Yeah anyway, there are options built into the mpp plug-in for this :)
k

kpgalligan

08/29/2019, 2:23 PM
The only thing you might want to do is name the dependency prefix
Stately’s classes are all prefixed with “Stately” in downstream exports
StatelyThreadLocalRef
Not a deal breaker by any means, though, as long as the prefix names are stable across releases…
a

alex009

08/29/2019, 2:25 PM
if you use
export
or transitive export - classes not prefixed
k

kpgalligan

08/29/2019, 2:25 PM
Ah. Interesting
Very good info. Thanks both. Now to sell the client…
b

basher

08/29/2019, 2:39 PM
Good luck!
Just checked and for Obj-C classes, everything gets the prefix used by the final framework