Writing a Swift framework, I'm wondering, can I compile this without using Xcode. I tried 'swift' with the -module options, but the 'swift' command does not seem to produce any output no matter what I do. 'swiftc' with the -parse-as-library gives an 'Undefined symbol _main' error
So, how can I compile a swift library without Xcode?
As of Swift 2.2 you can use swiftc
to compiles a swiftmodule
directly from the command line using the -emit-module
flag like this:
$ swiftc -emit-module MyClass.swift
$ ls
MyClass.swift
MyClass.swiftdoc
MyClass.swiftmodule
Use the --help
flag to see the full list of options. Also see Creation of pure Swift module 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
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