Does anyone have any advice around modularization ...
# multiplatform
p
Does anyone have any advice around modularization or know of any documentation or project samples for multi-module KMM compiling to XCFramework? I have a highly modularized project and would prefer to have a single framework generated for use by my iOS App. I included dependencies to my KMM app in iosMain via
api(project(":some:domain"))
, but when I look at the generated header files in the framework, I don't see any reference to the classes in some:domain
j
We put dummy functions into the final module which expose the types we want to expose from upstream dependencies
p
Any reason you opt to do that over using
export
in the framework definition? Just less verbose output and tighter control over what is exposed?
j
Hmm I don't know how to use export
We're a big org and all of this was already set up when I rejoined so I just know this is one way I was told to make it work
p
ah ok, I just found it myself
r
public declarations have a significantly bigger binary size impact than private/internal functions. So when you export a library with a large API surface it can be bad for your overall app size. Dummy functions can be a convenient hack to expose only the stuff you specifically want from your dependencies.
p
great insight, thanks. will definitely take that into account
s
If your plan is to integrate your code with only one iOS app and not redistribute the framework, an XCFramework is going to be overkill. Just go with the embed and sign framework task mentioned in the docs or use the CocoaPods method of integration.
g
I asked a kind of similar question the other day and there was some helpful discussion in the thread. (+ also has an example usage of the
export()
function)
p
ah yes, super helpful, would have saved me some time if I had found that thread. thanks!!
👍 1