From the Swift REPL, how do I get a list of available modules?

From the Swift REPL, I can import framework modules like Foundation by doing import Foundation.

What command can I give on the REPL that will produce a list of all the modules which are available to be imported?

  • Determine image MB size from PHAsset
  • Simple Swift class does not compile
  • New to swift, my program will crash pressing open
  • IOS Bluetooth not discovering peripheral services. (sometimes!)
  • WKWebView notification when view is actually shown
  • Swift Custom Back Button and Destination

    Just to be really clear what I’m trying to understand. On the REPL, if I type the words “import Foundation” then I can access the Foundation types, constants, etc.. If I type the words “import CoreGraphics” then I can access CoreGraphics. If I have the 3rd party library OptionKit installed, then typing “import OptionKit” lets me use OptionKit. These are all modules which can be directly imported from the REPL.

    Some modules or frameworks, however, cannot. For instance, if I type “import ParseOSX” from the REPL, I get an error, even though it is possible to do “import ParseOSX” from a standalone script.

    What I want to understand is just, how do I determine the list of frameoworks or modules which I can import, from the REPL, by using the import command.


    I’ve done a little searching and it seems like the only 3rd-party framework I’ve successfully imported from /Library/Frameworks, OptionKit, is also the only one with a .swiftmodule file. And all the importable Apple frameworks seem to have their own .swiftmodule files, which you can find by searching under /Application/

    So this suggests you can import at runtime only the framework with .swiftmodule files. But I’m not sure of this.

    Solutions Collect From Internet About “From the Swift REPL, how do I get a list of available modules?”

    If you’re looking simply for the list, you might want to use:

    :target modules list 

    That returns the full list of modules. Hope this help.