Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile swift module/framework/library without xcode

Tags:

xcode

swift

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?

like image 735
SomeNorwegianGuy Avatar asked Nov 01 '22 04:11

SomeNorwegianGuy


1 Answers

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
like image 181
chakrit Avatar answered Nov 13 '22 07:11

chakrit