SomeNorwegianGuy
SomeNorwegianGuy

Reputation: 1534

Compile swift module/framework/library without xcode

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?

Upvotes: 5

Views: 818

Answers (1)

chakrit
chakrit

Reputation: 61518

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

Upvotes: 2

Related Questions