When a swift framework is built, where do the public header for the classes/functions stored? The reason I ask is because when I open the framework in finder there is a Headers folder that has two headers, but they don't contain my public classes/functions. When I import the framework into a swift project and I "command+left click" i get a list of import statements and my public classes and functions. How can I find this file in a framework folder structure?
Where are the Swift function declarations?
Swift doesn’t use headers, even when you create a framework. Rather, Swift exports the framework’s interface via a module. Check out the
Modules
directory within your framework. This is a binary file, so you won’t be able to read it like you would a header.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
So there is a module.modulemap file which has
framework module Framework1 {
umbrella header "Framework1.h"
export *
module * { export * }
}
module Framework1.Swift {
header "Framework1-Swift.h"
}
This tells me nothing about what is public.
Within the same folder as module.modulemap, there is a folder named Framework1.swiftmodule which has x86_64.(swiftdoc|swiftmodule) files. These files list nothing to a developer who would like to peak into what is public.
Right. As I said, Swift doesn’t use text-based headers. However, if you add the framework to a client project, import it in Swift, and then command-click on the framework name, Xcode will show you its public interface. For example, for a framework called
QFramework
, the import would look like this:
import QFramework
and command-clicking on
QFramework
would reveal its public interface.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
That's what I thought. Thanks.