Have fun:
#! /bin/sh # usage: <shellscript> typename # All credit to @mikeash echo "import Cocoa\n:print_decl $1" | xcrun swift -integrated-repl | open -f
Some points:
- Replace xcrun swift with a path as needed (e.g. /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift) if you haven’t selected 6-Beta.
- No support for UIKit from the command line
- Case matters
5 Comments
Thanks for the tip! This led me to the solution of a problem that bothered me since Beta 4 removed the swift-ide-test command: How to dump all the declarations in a module:
echo “:print_module CoreGraphics” | xcrun swift -integrated-repl
Oh very nice!
In Beta 6, the option has been changed to `-deprecated-integrated-repl`.
For UIKit:
echo “import UIKitn:print_decl UIDevice” | xcrun swift -deprecated-integrated-repl -sdk /Applications/Xcode6-Beta6.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk -v | open -f
Is something like “:print_module” still available? How did you even discover this function? I’ve been trying to understand how to get a list of available modules, and I’m clueless. (I put up an SO question which hasn’t generated any insight either: http://stackoverflow.com/questions/26881926/from-the-swift-repl-how-do-i-get-a-list-of-available-modules )