我对斯威夫特完全陌生。它刚刚作为 Linux 的开源版本发布,我想尝试一下。这是在 ubuntu 14.04 上。 clang 已根据先决条件安装。
<Edit>
: 要求在这里 https://github.com/apple/swift#system-requirements也在 ubuntu 14.04 上请求 clang 版本 3.6。我首先使用 clang 3.4 尝试了这些第一步,但后来按照链接中的说明更新到 3.6 并重试。相同的结果。</Edit>
我已经下载了https://swift.org/builds/ubuntu1404/swift-2.2-SNAPSHOT-2015-12-01-b/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz https://swift.org/builds/ubuntu1404/swift-2.2-SNAPSHOT-2015-12-01-b/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz到〜/下载/。安装记录和 swift 第一步:
$ cd /tmp
$ tar xf ~/Downloads/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz
$ PATH=/tmp/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/bin/:"$PATH"
$ clang++ --version
Ubuntu clang version 3.6.0-2ubuntu1~trusty1 (tags/RELEASE_360/final) (based on LLVM 3.6.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ which swift
/tmp/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/bin//swift
$ swift --version
Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c)
Target: x86_64-unknown-linux-gnu
$ swift
Welcome to Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c). Type :help for assistance.
1> 1 + 2
opening import file for module 'SwiftShims': No such file or directory
1>
根据本入门指南 https://swift.org/getting-started/#using-the-repl它应该打印出来
$R0: Int = 3
出了什么问题以及如何修复它?
编辑:尝试手动查找该文件:它显然不包含在安装中:
$ find swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/ | grep -i shims
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/FoundationShims.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/SwiftStddef.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/module.map
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/UnicodeShims.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/GlobalObjects.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/HeapObject.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/RuntimeShims.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/RefCount.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/RuntimeStubs.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/LibcShims.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/CoreFoundationShims.h
swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/shims/SwiftStdint.h
编辑:当我尝试swift build你好世界的例子 https://swift.org/getting-started/#using-the-build-system,产生以下输出:
/tmp/Hello$ swift build
<unknown>:0: error: opening import file for module 'Swift': No such file or directory
swift-build: exit(1): ["/tmp/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/bin/swiftc", "--driver-mode=swift", "-I", "/tmp/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/pm", "-L", "/tmp/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/lib/swift/pm", "-lPackageDescription", "/tmp/Hello/Package.swift"]
编辑:截至2015年12月22日的新发现
自从我发布这个问题以来,至少又发布了两个 swift for linux 的快照:2015-12-10 和 2015-12-18。我已经尝试过这些,但它们不能解决问题。
此邮件列表主题位于此处(post 1 https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20151130/000134.html, post 2 https://lists.swift.org/pipermail/swift-users/Wsteek-of-Mon-20151130/000136.html, post 3 https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20151207/000196.html)是关于同样的问题。有人建议在主目录下安装 swift 会有帮助。这对我的情况没有帮助,错误消息仍然相同。
更有趣的是,该邮件列表线程包含使用 strace 创建的 REPL 错误分析 https://gist.github.com/solidsnack/d902a761877b0f797835。将特定的 strace 输出与 REPL 工作的系统的 strace 输出进行比较会很有趣。
编辑:截至 2015 年 12 月 26 日的更多信息:
新的 swift 版本已发布,日期为 2015 年 12 月 22 日。此版本也存在同样的问题。
关于此问题的另一个线程已出现在 swift 邮件列表中从这里开始 https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20151221/000592.html。遇到该问题的用户也发帖此处的 strace 输出 http://pastebin.ubuntu.com/14161487/.