Expose Classes of Dependencies in Swift Framework
There is no way in Swift to make importing one module automatically import another. That was a conscious choice on the language designers’ part, and Swift is strict about it.
There is something called an “umbrella framework” which sort of does what you want by letting you create a facade for several subframeworks, but Apple specifically discourages you from creating one.
Barring that, you must ensure that (in your example) fetchData()
and CoreStruct
are compiled into the same framework, which you could do by:
- having
MyFramework
includeCoreFramework
’s code as a git submodule, - having
MyFramework
use Cocoapods to buildCoreFramework
within the same workspace (i.e. publishCoreFramework
as a pod, and include it inMyFramework
without theuse_frameworks
option in the podfile, so that you get two projects in one workspace compiled into one framework), - merging the projects (i.e. just add all the source files from
MyFramework
andCoreFramework
to the same project),
…or anything else that causes the two source trees to be compiled into one framework.