Compile swift module / framework / library without xcode
Writing a Swift framework, I'm wondering if I can compile this without using Xcode. I tried "swift" with the -module options, but the "swift" command doesn't seem to produce any output no matter what I do. 'swiftc' with -parse-as-library gives error Undefined _main '
So how can I compile the swift library without Xcode?
source to share
As of Swift 2.2, you can use swiftc
to compile swiftmodule
directly from the command line using a flag -emit-module
like this:
$ swiftc -emit-module MyClass.swift
$ ls
MyClass.swift
MyClass.swiftdoc
MyClass.swiftmodule
Use the flag --help
to see a complete list of parameters. Also see Creating a Pure Swift Module on the blog post for a more complete tutorial.
Apple Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)
Target: x86_64-apple-macosx10.9
source to share