Example library showing how to break a library into multiple modules, but only require the consuming app to use a single import statement.
For two targets, MainTarget
and CoreTarget
, where MainTarget
depends on CoreTarget
, we want to be able to write:
import MainTarget
And that is it, not:
import CoreTarget
import MainTarget
This is possible, if in MainTarget
, as done in this example project, this is added:
@_exported import CoreTarget
It will not prevent users/consumers of MainTarget
from manually importing CoreTarget
, but it will not be required.
Note that this is an experimental feature.
Create XCFrameworks with:
swift create-xcframework CoreTarget MainTarget --zip
Note that all targets need to be listed.
To see how to distribute as XCFrameworks, look at the following repo: https://github.com/mhays118/TestDistributingXCFrameworks
For example consuming app (with single import), see: https://github.com/mhays118/TestSPMLibraryConsumerApp