From the first beta of Swift, we have been able to see the Swift interface for a module through an interactive process. You start with a Swift file in an Xcode project, right-click on a symbol, and choose "Jump to Definition"; Xcode will generate a file with the declaration.
That procedure is a bit tedious. It's very manual; you have to start with a Swift file in an Xcode project; and you have to know the name of the symbol in advance. It doesn't generate all the declarations in the module — if the module was defined in Objective-C, it only shows declarations from a single .h file.
I learned about the command-line tool swift-ide-test in Beta 3 via http://www.jpsim.com/uncovering-sourcekit/. By using a command like the following, I could generate the declarations for an entire framework:
xcrun swift-ide-test -print-module -source-filename /dev/null \
-sdk /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk \
-print-regular-comments -module-print-submodules -module-to-print CoreGraphics
However, in Beta 4 the swift-ide-test command has disappeared.
Does anyone know the new way to automatically generate Swift declarations via the command line?
I figured out a technique, based on a blog post by Erica Sadun (http://ericasadun.com/2014/07/28/swift-docs-generation/).
The Swift REPL has a :print_module
command that dumps all the declarations in the module. Unlike choosing a module in Xcode, it doesn't stop at just one (virtual) header.
So this command will print out all the declarations in CoreGraphics:
echo ":print_module CoreGraphics" | xcrun swift -deprecated-integrated-repl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With