How do I create an importable module in Swift?

sprinter picture sprinter · Jun 4, 2014 · Viewed 32.3k times · Source

I have read through Apple's documentation for Swift and can find nothing about how to create modules or how to define class or stucture members as private or public.

There are references to the import statement in the syntax but I can find no information on what it does or how to use it.

Does anyone know where I can find this?

Answer

Austin picture Austin · Jun 4, 2014

In Swift, "Modules" refers to Frameworks. Xcode now has a template for creating a framework project for both iOS and OS X.

There is currently no way to declare methods or properties public / protected. If you would like to see this added as a feature, you can make a feature request on Apple's bug reporter. It should also be noted that Apple has stated that the language could change with each release of Xcode, so it is possible that member access levels could be added before the public release.