This repository demonstrates a technique that you can use to create a .swiftmodule
file for a .dylib
without having
access to the original .swift
file.
Steps:
- Analyze the
.dylib
usingnm -gU libModule.dylib
- Use
xcrun swift-demangle
to reconstruct the structure of the library - Create a mock implementation of the Swift module (see
Module.swift
) - Use the mock implementation to generate the
.swiftdoc
and.swiftmodule
files - Compile your program (
main.swift
) using the mock.swiftmodule
and link it against the real dylib (libModule.dylib
)
Acknowledgements:
- Thanks to Michael Gianarakis for sharing the slides from his Reverse Engineering Swift Apps talk that introduced me to
swift-demangle