An experimental AI-assisted video editor that bridges Swift and Rust. The Swift UI drives workflows while a Rust core performs compute-heavy and systems tasks. The app integrates with OpenAI for language/assistant features and AssemblyAI for speech-to-text/transcription.
Use cases this editor aims to support:
- Transcribe audio tracks to text (AssemblyAI)
- Generate/edit scripts, captions, or summaries with LLMs (OpenAI)
- Orchestrate edit decisions via a fast Rust core surfaced to Swift UI
Note: Features may still be evolving; this README focuses on setup and configuration so you can build and run the project successfully.
- Swift App: iOS/macOS application with UI and app logic
- rust-core: Rust library providing native functionality exposed to Swift via FFI
- Xcode (latest stable recommended)
- Rust toolchain (install via https://rustup.rs)
- cbindgen (cargo install cbindgen)
- macOS for development. iOS Simulator or a device for iOS targets.
- Build the Rust library
-
From the project root, run the build script that compiles and places the Rust static library where Xcode expects it:
cd "Swift App" ./build-rust.sh
- Open the Xcode project
- Open Swift App/AI Video Editor.xcodeproj
- Link the Rust library in Xcode (if not already configured)
-
Swift Compiler - General > Objective-C Bridging Header:
$(PROJECT_DIR)/AI Video Editor/AI-Video-Editor-Bridging-Header.h -
Search Paths > Header Search Paths:
$(PROJECT_DIR)/AI Video Editor/Libs -
Linking > Other Linker Flags:
-lrust_core -
Search Paths > Library Search Paths:
$(PROJECT_DIR)/AI Video Editor/Libs
- Add a Run Script build phase
-
Ensure a Run Script phase runs before "Compile Sources":
"${PROJECT_DIR}/build-rust.sh"
- Configure API keys in Xcode (OpenAI and AssemblyAI)
- In Xcode, select Product > Scheme > Edit Scheme…
- Select the Run action, then the Arguments tab
- Under Environment Variables, add the following key/value pairs:
- OPENAI_API_KEY = your_OpenAI_key
- ASSEMBLYAI_API_KEY = your_AssemblyAI_key
- Make sure the checkboxes are enabled so they’re passed to the app process
How the app accesses these keys:
-
In Swift:
import Foundation let openAIKey = ProcessInfo.processInfo.environment["OPENAI_API_KEY"] let assemblyAIKey = ProcessInfo.processInfo.environment["ASSEMBLYAI_API_KEY"]
-
In Rust (if needed on the native side):
use std::env; let openai = env::var("OPENAI_API_KEY").ok(); let assembly = env::var("ASSEMBLYAI_API_KEY").ok();
Important notes about environment variables:
- Environment variables from the Xcode scheme are available when launching from Xcode (macOS app and iOS Simulator). They may not be present when launched outside Xcode (e.g., TestFlight, App Store). For distribution builds, consider a secure key management approach (Keychain, encrypted config, remote configuration) instead of environment variables.
- Never hardcode API keys in source control.
- Build and run
- Choose the desired target (macOS app or iOS Simulator) and press Run.
The Swift app communicates with Rust via a C-compatible FFI layer:
- Rust functions are exported with #[no_mangle] extern "C"
- A C header (rust_core.h) declares the exported API
- Swift imports that header through a bridging header
- A Swift wrapper (e.g., RustCore.swift) presents a Swift-friendly interface
To add functionality end-to-end:
- Rust: Add or update functions in rust-core/src/lib.rs and the C header in rust-core/include/rust_core.h
- Swift: Wrap new functions in Swift App/AI Video Editor/RustCore.swift
- UI: Update views in Swift App/AI Video Editor/ContentView.swift (or other UI files)
- Build: Ensure build-rust.sh exports the new symbols and the library is rebuilt
- Library not found / linker errors
- Re-run the build script so the Rust static library is up-to-date and copied to Swift App/AI Video Editor/Libs
- Verify Library Search Paths and Other Linker Flags in the Xcode target
- Bridging header / missing symbols
- Confirm the bridging header path matches the actual file name and location
- Ensure the generated header from cbindgen matches the Rust exports
- Environment variables not found at runtime
- Confirm you set them in the active Scheme > Run > Arguments and that they’re checked
- iOS on-device builds launched outside Xcode won’t inherit scheme variables—use a secure runtime configuration approach for production
- Keep OPENAI_API_KEY and ASSEMBLYAI_API_KEY out of source control and logs
- Use environment variables for local development only; for production, prefer a secure secret management approach (Keychain, server-provided tokens, or remote config)