如何打开 .swiftmodule 文件

Ant*_*gin 4 xcode ios swift

我想.swiftmodule从 iOS 框架检查文件的公共内容。

在这里(https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20160111/000827.html)我找到了一个使用建议swift-ide-test

您可以使用 swift-ide-test 工具来转储模块的公共接口,但命令行界面没有它应有的漂亮:

swift-ide-test -print-module -source-filename=dummy.swift -module-to-print=MyApp

...加上查找模块及其所有依赖项所需的任何 -I 或 -F 路径。如果您使用的是 Mac,则需要在开头插入“xcrun -sdk macosx”或“xcrun -sdk iphoneos”以查找系统标头。

不幸的是,当我尝试xcrun -sdk iphoneos swift-ide-test使用 Xcode 10.1运行时,出现以下错误:

$ xcrun -sdk iphoneos swift-ide-test
xcrun: error: unable to find utility "swift-ide-test", not a developer tool or in PATH
Run Code Online (Sandbox Code Playgroud)

似乎此工具已从 Xcode 中删除。

关于如何打开.swiftmodule文件的任何其他想法?

Ant*_*gin 8

经过几个小时的努力,我找到了一种从 iOS 框架检查模块公共内容的 IMPLICIT 方法。

这个技巧是通过:print_module在 Swift REPL 中使用命令来完成的。

更准确地说,您需要使用指向您的框架的路径启动 Swift REPL:

swift -F <path to a folder with LibName.framework> -deprecated-integrated-repl
Run Code Online (Sandbox Code Playgroud)

现在您可以使用:print_module带有框架名称的命令:

(swift) :print_module LibName
Run Code Online (Sandbox Code Playgroud)

资料来源:

/sf/answers/1951748431/

/sf/answers/1750381181/

/sf/answers/2536463051/

PS swift 源仍然有swift-ide-test工具的源代码(https://github.com/apple/swift/tree/master/tools/swift-ide-test),所以另一种查看 swiftmodules 内容的方法是编译这个工具,但我没有进一步研究这个解决方案。

  • 似乎不再工作:`编译器内部集成的 REPL 已被删除;请改用 LLDB 增强型 REPL。` (2认同)