https://github.com/veracode/gen-ir
Generates LLVM IR for Xcode Projects
https://github.com/veracode/gen-ir
Last synced: 6 months ago
JSON representation
Generates LLVM IR for Xcode Projects
- Host: GitHub
- URL: https://github.com/veracode/gen-ir
- Owner: veracode
- License: mit
- Created: 2022-12-07T13:39:36.000Z (over 3 years ago)
- Default Branch: develop
- Last Pushed: 2025-12-22T15:17:44.000Z (7 months ago)
- Last Synced: 2025-12-24T02:26:46.157Z (7 months ago)
- Language: Swift
- Size: 706 KB
- Stars: 10
- Watchers: 7
- Forks: 6
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
Gen IR 🧞♂️
Generate LLVM IR from an Xcode Build Log
This tool was heavily inspired by [a DigitalRickshaw blog post](https://blog.digitalrickshaw.com/2016/03/14/dumping-the-swift-ast-for-an-ios-project-part-2.html) ❤️
## Prerequisites
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.
## Install
```bash
if ! command -v brew >/dev/null 2>&1; then
echo "Homebrew is not installed. Visit https://brew.sh/ to install it."
return 1 2>/dev/null || true
else
echo "Installing gen-ir using Homebrew" &&
brew tap veracode/tap &&
brew install gen-ir &&
echo "gen-ir installed successfully."
echo "For usage instructions, see:"
echo " https://github.com/veracode/gen-ir#readme"
fi
```
## Update (if previously installed)
```bash
brew upgrade gen-ir
```
## 🎉 Done
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.
## Usage
> ### ⚠️ Before you use
>
>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.
>
> Due to a bug in Xcode you **must** run the clean and archive commands _separately_. This means you need to do a `xcodebuild clean` and _then_ an `xcodebuild archive` and not `xcodebuild clean archive`.
`gen-ir` takes a Xcode build log by two means, a path to a file or stdin:
```bash
# Path to build log (you can export from inside of Xcode too)
xcodebuild clean && \
xcodebuild archive -project TestProject.xcodeproj -scheme TestProject -configuration Debug -destination generic/platform=iOS -archivePath TestProject.xcarchive > build_log.txt
gen-ir build_log.txt TestProject.xcarchive
# Stdin (you may need to redirect stderr to stdout here, Xcode is weird about writing to it sometimes)
xcodebuild clean && \
xcodebuild archive -project TestProject.xcodeproj -scheme TestProject -configuration Debug -destination generic/platform=iOS -archivePath TestProject.xcarchive | gen-ir - TestProject.xcarchive
```
## Building
`gen-ir` is implemented as a Swift Package, so you can either open [`Package.swift`](Package.swift) in an IDE or build via the command line:
```sh
# Debug output: ./.build/debug/gen-ir
swift build
# Release output: ./.build/release/gen-ir
swift build -c release
```
## Remove older version
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:
```sh
brew uninstall gen-ir &&
brew untap NinjaLikesCheez/tap
```