在没有xcode的情况下编译swift模块/框架/库

时间:2015-05-11 11:49:46

标签: xcode swift

编写一个Swift框架,我想知道,我可以在不使用Xcode的情况下编译它。 我试过快速的#39;使用-module选项,但是' swift'无论我做什么,命令似乎都不会产生任何输出。 ' swiftc'使用-parse-as-library可以得到一个未定义的符号_main'错误

那么,如何在没有Xcode的情况下编译swift库?

1 个答案:

答案 0 :(得分:2)

从Swift 2.2开始,您可以使用swiftc直接从命令行使用swiftmodule标志编译-emit-module,如下所示:

$ swiftc -emit-module MyClass.swift
$ ls
MyClass.swift
MyClass.swiftdoc
MyClass.swiftmodule

使用--help标志查看完整的选项列表。另请参阅Creation of pure Swift module博客文章以获取更完整的教程。

Apple Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)
Target: x86_64-apple-macosx10.9
相关问题