This tool was heavily inspired by: https://blog.digitalrickshaw.com/2016/03/14/dumping-the-swift-ast-for-an-ios-project-part-2.html ❤️
To build the tool, you'll need Xcode 14 and macOS 12.5 or greater.
To install and run the tool, you'll need Homebrew, Xcode, and macOS 12 or greater.
# If you don't have brew installed, install it: https://brew.sh/
# Add the brew tap to your local machine
brew tap veracode/tap
# Install the tool
brew install gen-ir
brew upgrade gen-ir
All installed! You can now use gen-ir
on your system - be sure to run gen-ir --help
to check the available commands and options.
It's important to know that
gen-ir
requires that a full build log is provided.This means a clean, fresh build of a project.
The compiler will not make a call for an object that doesn't need to be rebuilt, and we will not be able to parse what doesn't exist. Ensure you do a clean before your build otherwise
gen-ir
may miss some modules.
gen-ir
takes a Xcode build log by two means, a path to a file or stdin:
# Path to build log (you can export from inside of Xcode too)
xcodebuild clean && \
xcodebuild build -project TestProject.xcodeproj -scheme TestProject -configuration Debug -destination generic/platform=iOS -archivePath TestProject.xcarchive > build_log.txt
gen-ir build_log.txt TestProject.xcarchive --project-path TestProject.xcodeproj
# Stdin (you may need to redirect stderr to stdout here, Xcode is weird about writing to it sometimes)
xcodebuild clean && \
xcodebuild build -project TestProject.xcodeproj -scheme TestProject -configuration Debug -destination generic/platform=iOS -archivePath TestProject.xcarchive | gen-ir - TestProject.xcarchive --project-path TestProject.xcodeproj
gen-ir
is implemented as a Swift Package, so you can either open Package.swift
in Xcode, or build via the command line:
# Debug output: ./.build/debug/gen-ir
swift build
# Release output: ./.build/release/gen-ir
swift build -c release
If you previously installed the test version during early access testing, run the following commands to remove the test version from your system before installing:
brew uninstall gen-ir &&
brew untap NinjaLikesCheez/tap