I have an Xcode project with a main app and a Swift Framework called Networking
. Now I'd like to split that Networking
module into a submodule with only some utility classes so that they are available to the main app only when explicitly imported. So the usage I'd like to achieve would be
import Networking
import Networking.Utils
// Public class in Networking
MyNetworking.doStuff()
// Public class in Networking.Utils
// Should not compile unless Networking.Utils is imported
MyNetworkingUtils.doSomething()
So my module has the following file structure
.
├── Core
│ ├── MyNetworking.swift
│ └── Networking.h
├── Info.plist
├── Utils
│ ├── NetworkingUtils.h
│ └── Utils.swift
└── module.modulemap
I created a custom module.modulemap
with this content:
framework module Networking {
umbrella header "Networking.h"
export *
module * { export * }
explicit module Utils {
header "NetworkingUtils.h"
}
}
This creates the Networking
module but the problem is that the Utils
classes are available in the main Networking
module.
The question is, how can I specify in the module map which Swift files (ideally subfolders) belong to which module
.
The Networking
has only Swift files so the umbrella .h
files are basically empty.
It looks like it's good option here to have two different modules: Networking and NetworkingUtils (second could have dependency to first).