What Are the Dependencies of vphone-cli? Swift and Python Libraries Explained

vphone-cli is a hybrid project that combines Swift 6.0 packages like swift-argument-parser and MachOKit with Python libraries including capstone and pymobiledevice3 to enable virtual iPhone emulation on macOS.

vphone-cli, developed by Lakr233, is an open-source tool that creates virtualized iPhone environments on macOS through a command-line interface. The dependencies of vphone-cli are split between two distinct ecosystems: a Swift-based virtualization frontend and Python-driven firmware manipulation utilities. According to the Lakr233/vphone-cli source code, this dual-stack architecture requires specific libraries from both the Swift Package Manager and Python Package Index.

Swift Package Manager Dependencies

The Swift portion of vphone-cli relies on third-party libraries and macOS system frameworks declared in the project's Package.swift manifest.

Third-Party Swift Libraries (Lines 12–17)

According to Package.swift at lines 12–17, vphone-cli imports five external Swift packages:

  • swift-argument-parser – Provides the ArgumentParser framework for defining and parsing CLI options in sources/vphone-cli/main.swift.
  • Dynamic – Enables runtime dispatch to private Apple APIs without requiring Objective-C bridges.
  • libcapstone-spm – A Swift wrapper around the Capstone disassembly engine, used by the firmware patcher to decode kernel binaries.
  • libimg4-spm – Swift wrapper for IMG4 handling, allowing manipulation of Apple firmware containers compatible with pyimg4-style operations.
  • MachOKit – Utilities for parsing and editing Mach-O binaries, required for re-signing extracted IPA files.

macOS System Frameworks (Lines 33–51)

The executable target defined at lines 33–51 links against essential macOS system frameworks rather than third-party libraries:

  • Virtualization – Core framework for creating and managing virtual machines.
  • AppKit and SwiftUI – Provide UI components for the interface.
  • CoreLocation – Handles location forwarding to the virtual device.
  • AVFoundation – Enables screen recording and audio functionality.

Python Runtime Dependencies

The auxiliary scripts for firmware patching and device interaction rely on Python packages listed in requirements.txt (lines 1–7).

Core Python Packages

  • typer – CLI builder for Python tooling interfaces.
  • capstone – Core disassembly engine utilized by Python patcher modules in sources/FirmwarePatcher/.
  • keystone-engine – Assembler counterpart for generating patched instruction bytes.
  • pyimg4 – Handles IMG4/IM4P firmware format parsing and manipulation.
  • pymobiledevice3 (≥ 9.5.0) – Provides higher-level iOS device communication utilities.
  • ipsw-parser – Parses Apple IPSW update bundles for firmware extraction.
  • setuptools – Standard build-time helper for Python packaging.

Dependency Integration in Source Code

The Swift packages integrate directly into the CLI entry point. In sources/vphone-cli/main.swift, the swift-argument-parser dependency enables structured command definitions:

import ArgumentParser

struct VPhoneCLI: ParsableCommand {
    @Flag(help: "Run the VM in DFU mode")
    var dfu: Bool = false

    func run() throws {
        // … launch VM based on parsed flags …
    }
}
VPhoneCLI.main()

For Python components, the project uses scripts/setup_venv.sh to initialize a virtual environment before running firmware operations:


# Activate the Python virtual environment first (created by `make setup_venv`)

source .venv/bin/activate

# Example: patch a kernel binary

python -m patchers.cfw --input kernel.bin --output kernel_patched.bin

The sources/FirmwarePatcher/ directory implements the logic that bridges Swift and Python dependencies, utilizing Capstone for disassembly and MachOKit for binary editing.

Summary

  • vphone-cli dependencies span two ecosystems: Swift Package Manager for the macOS virtualization frontend and Python packages for firmware manipulation.
  • Swift third-party libraries include swift-argument-parser, Dynamic, libcapstone-spm, libimg4-spm, and MachOKit, declared in Package.swift lines 12–17.
  • System frameworks (Virtualization, AppKit, SwiftUI, CoreLocation, AVFoundation) are required for VM creation and UI, listed in lines 33–51.
  • Python runtime dependencies include typer, capstone, keystone-engine, pyimg4, pymobiledevice3, ipsw-parser, and setuptools from requirements.txt lines 1–7.
  • Key integration files include sources/vphone-cli/main.swift for Swift CLI logic and scripts/setup_venv.sh for Python environment setup.

Frequently Asked Questions

Does vphone-cli require Python to run?

Yes, vphone-cli requires Python for its firmware patching and device interaction scripts. While the main virtualization interface is built in Swift 6.0, the requirements.txt dependencies—including pymobiledevice3 and pyimg4—must be installed in a virtual environment via scripts/setup_venv.sh for full functionality.

What is libcapstone-spm used for in vphone-cli?

libcapstone-spm is a Swift wrapper around the Capstone disassembly engine used in sources/FirmwarePatcher/ to decode kernel binaries during firmware patching. It allows the application to analyze ARM64 instruction sets within iOS kernels without leaving the Swift ecosystem.

Which macOS frameworks enable the virtualization features?

The Virtualization framework provides the core VM creation capabilities, while AppKit and SwiftUI handle the interface. CoreLocation forwards location data to the virtual device, and AVFoundation manages screen recording—all declared as dependencies in Package.swift lines 33–51.

How are Python dependencies managed in the project build process?

Python dependencies are managed through requirements.txt (lines 1–7) and installed via scripts/setup_venv.sh, which creates a local .venv directory. This isolation ensures that capstone, keystone-engine, and other patching tools remain separate from the system Python installation.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →