【问题标题】:How to open a .swiftmodule file如何打开 .swiftmodule 文件
【发布时间】:2018-11-21 16:39:36
【问题描述】:

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

在这里 (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" 在开始查找系统 标题。

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

$ xcrun -sdk iphoneos swift-ide-test
xcrun: error: unable to find utility "swift-ide-test", not a developer tool or in PATH

似乎这个工具已从 Xcode 中删除。

关于如何打开.swiftmodule 文件还有其他想法吗?

【问题讨论】:

  • 你不应该能够看到 iOS 的源代码。
  • 我想检查我的自定义iOS框架是否编译正确

标签: ios swift xcode


【解决方案1】:

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

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

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

swift -F <path to a folder with LibName.framework> -deprecated-integrated-repl

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

(swift) :print_module LibName

来源:

https://stackoverflow.com/a/27882120/2241008

https://stackoverflow.com/a/25005445/2241008

https://stackoverflow.com/a/36235186/2241008

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

【讨论】:

    【解决方案2】:

    [.swiftmodule]

    您可以:

    1. 将此框架添加到框架中
    2. 导入框架import &lt;module_name&gt;
    3. Jump to Definition

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-11
      • 2011-01-23
      • 2013-11-20
      • 2015-01-30
      • 2010-09-15
      • 1970-01-01
      • 1970-01-01
      • 2018-07-28
      相关资源
      最近更新 更多