A Swift wrapper for Radare2, the popular reverse engineering framework. This package provides a modern, async/await-based Swift API for working with Radare2's powerful binary analysis capabilities.
- Async/Await API: Modern Swift concurrency support with async/await
- Type Safety: Strongly typed interfaces for Radare2 functionality
- Cross-Platform: Supports macOS 11+, iOS 13+, and non-Apple platforms (e.g. Linux) via system radare2
- Thread Safe: Safe concurrent access to Radare2 core functionality
Add SwiftyR2 to your Swift package dependencies:
dependencies: [
.package(url: "https://github.com/radareorg/SwiftyR2.git", from: "1.0.0")
]import SwiftyR2
// Create a new Radare2 core instance
let core = await R2Core.create()
// Execute a command and get the output
let output = await core.cmd("?V")
print("Radare2 version: \(output)")
// Access configuration
let config = core.config
await config.set("asm.arch", "x86")// Open a binary file
await core.cmd("o /path/to/binary")
// Analyze the binary
await core.cmd("aaa")
// Print function information
let functions = await core.cmd("afl")
print("Functions:\n\(functions)")// Set analysis options
await core.config.set("analysis.depth", "10")
await core.config.set("asm.bits", "64")
// Get current settings
let arch = await core.config.get("asm.arch")
print("Current architecture: \(arch)")- Swift 5.9+
- macOS 11.0+, iOS 13.0+, or any other Swift-supported platform
- Xcode 14+ (Apple platforms)
- radare2 system library via pkg-config (non-Apple platforms)
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the same license as Radare2. See LICENSE.md for details.