Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a .swiftmodule file

Tags:

xcode

ios

swift

I want to check a public content of a .swiftmodule file from an iOS framework.

Here (https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20160111/000827.html) I've found a suggestion to use swift-ide-test:

You can use the swift-ide-test tool to dump the public interface for a module, but the command-line interface is less pretty than it should be:

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

…plus any -I or -F paths necessary to find your module and all its dependencies. If you're on a Mac, you'll need to insert "xcrun -sdk macosx" or "xcrun -sdk iphoneos" at the start to find the system headers.

Unfortunately, when I try to run xcrun -sdk iphoneos swift-ide-test with Xcode 10.1, I get following error:

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

Seems that this tool was removed from Xcode.

Any other ideas on how to open a .swiftmodule file?

like image 631
Anton Malmygin Avatar asked Jan 27 '23 03:01

Anton Malmygin


1 Answers

After few hours of struggling, I've found an IMPLICIT way of checking a public content of modules from an iOS framework.

The trick is done by using :print_module command inside the Swift REPL.

More precisely, you need to launch Swift REPL with a path to your framework:

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

Now you can use :print_module command with a name of your framework:

(swift) :print_module LibName

Sources:

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

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

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

P.S. swift sources still have a source code for swift-ide-test tool (https://github.com/apple/swift/tree/master/tools/swift-ide-test), so another way to see contents of swiftmodules will be in compiling this tool, but I did not investigated this solution any further.

like image 121
Anton Malmygin Avatar answered Feb 03 '23 18:02

Anton Malmygin