Skip to content

Darvisim/LLVM-On-iOS

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

167 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LLVM on iOS

A modernized showcase of using LLVM and Clang to provide native JIT scripting capabilities in an iOS application.

Edit the program screenshot Interpret the program screenshot

Overview

This project demonstrates how to embed the LLVM/Clang interpreter (ORC JIT) into a SwiftUI-based iOS app. It allows you to write C++ code directly on your iPad or iPhone, compile it in-memory, and execute it using a modernized bridge.

Key Features

  • LLVM 15+ Integration: Uses modern ORC JIT APIs.
  • Robust Build System: Modular build-llvm.sh script replacing complex legacy Xcode steps.
  • Universal XCFrameworks: Supports iOS Device, Simulator (Intel/Apple Silicon), and Mac Catalyst.
  • Modern SwiftUI UI: Optimized for iOS 15.0+.

Getting Started

1. Build or Download LLVM

To use this project, you need LLVM.xcframework and libffi.xcframework.

Option A: Build from Source (Recommended)

Our new modular build script handles fetching sources, building for all architectures, and packaging.

chmod +x build-llvm.sh
./build-llvm.sh libffi-all
./build-llvm.sh llvm-all

Requires Xcode 16.4+, CMake, and Ninja.

Option B: Download Prebuilt

Download the latest XCFrameworks from our GitHub Releases and place them in the root directory.


Project Structure

  • Sample/: The iOS Application source code.
    • Interpreter.cpp: The C++ core that manages the Clang Driver and ORC JIT.
    • LLVMBridge.mm: Objective-C++ bridge that safely passes data between Swift and C++.
    • ContentView.swift: SwiftUI interface for code editing and result display.
  • build-llvm.sh: The unified build script for all dependencies.

Known Limitations

  • JIT & Code Signing: iOS generally prevents executing unsigned code in memory (JIT).
  • Tethered Execution: The JIT interpreter works perfectly when the app is launched from Xcode (via the debugger).
  • Untethered Execution: To run JIT untethered, you typically need specific entitlements (e.g., com.apple.developer.kernel.get-task-allow). Without these, the OS may terminate the app on JIT execution due to security policies.

License

This project is provided with NO license attached—feel free to use, modify, and distribute it for any purpose.

About

Script to build LLVM and Clang projects for use in iOS app and example iOS app using LLVM to interpret C++ programs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Shell 100.0%