iOS Platform
engine-core, engine-platform, engine-render-device, engine-gfx, engine-ui, and the stage crates build for aarch64-apple-ios (device) and aarch64-apple-ios-sim (Apple silicon simulator). All iOS-specific code sits behind cfg(target_os = "ios") or the shared metal cfg used by macOS and iOS alike.
Differences from macOS
- Metal — Uses the same Metal backend (
objc2-metal).CAMetalDisplayLinkrequires iOS 17, so the default deployment target is17.0(IPHONEOS_DEPLOYMENT_TARGET). - SDL3 — Linked statically (
libSDL3.a).sdl3-sysenables itsno-linkfeature on iOS, andengine-gfx's build script linkslibSDL3.aand the required Apple frameworks once. - Entry point — UIKit owns the main thread: an app's
maincallsengine_platform::ios::run_app(app), and SDL invokesappon the main thread after launch. - Lifecycle —
engine_platform::ios::watch_lifecycle(started byPlatform::new) interceptsSDL_EVENT_WILL_ENTER_BACKGROUNDandSDL_EVENT_DID_ENTER_FOREGROUNDimmediately so no GPU work submits while backgrounded (which iOS terminates).engine_ui::HostemitsEvent::BackgroundandEvent::Foreground, skips presentation while backgrounded, and redraws on return. - Touch, safe area, orientation, scale —
Event::Touch { finger, phase, x, y, pressure }arrives in logical pixels alongside synthesized pointer events.Host::safe_area(),Host::orientation(), andHost::pixel_density()report display geometry; changes emitEvent::Resize. - Bundle files —
engine_platform::ios::bundle_directory()(SDL_GetBasePath) locates the app bundle;engine_assets::bundled_assetsresolvesassets/inside it automatically. - Not available on iOS —
Host::native_windowis null, windows cannot be moved or resized, folder dialogs and system cursors are no-ops, and BC-compressed textures are unavailable on iOS GPUs.
Building Static SDL3
Build SDL3 from an official source release using CMake, Ninja, and Xcode (keep source and build output outside the repository):
curl -LO https://github.com/libsdl-org/SDL/releases/download/release-3.4.20/SDL3-3.4.20.tar.gz
tar xzf SDL3-3.4.20.tar.gz
bun build/sdl3-ios.ts SDL3-3.4.20 sdl3-ios
export ENGINE_SDL3_IOS_DIR=$PWD/sdl3-ios # contains iphoneos/ and iphonesimulator/ with libSDL3.aShaders
Compile Metal libraries for both iOS SDKs alongside macOS:
bun build/build.ts shaders --iosThis writes metal-iphoneos/ and metal-iphonesimulator/ beside metal/ in the shader directory. Point ENGINE_SHADER_DIR to that directory when building for iOS; each crate's build script selects the matching SDK folder.
Host stage materials and post steps built with bun build/stage-materials.ts --ios select metal/, metal-iphonesimulator/, or metal-iphoneos/ automatically via cfg attributes, requiring no iOS-specific host build script logic.
Building & Running Samples
Run from the Xodó repository root:
export ENGINE_SDL3_IOS_DIR=/path/to/sdl3-ios
export ENGINE_SHADER_DIR=$PWD/target/build/device-shaders
export IPHONEOS_DEPLOYMENT_TARGET=17.0
cargo build --locked --target aarch64-apple-ios-sim -p engine-ui
bun samples/ios-ui/run.ts --device "iPhone 17" --screenshot shot.png
bun samples/ios-stage/run.ts --device "iPhone 17" --screenshot shot.pngsamples/ios-ui and samples/ios-stage are standalone workspaces. run.ts compiles for the simulator, bundles the .app, ad-hoc signs it, and installs/launches via xcrun simctl. For physical devices, compile for aarch64-apple-ios, package into a bundle with the same Info.plist, and sign with a development identity and provisioning profile.