Build mobile apps with Xu
Xu 0.13.1 generates ARM64 projects for iOS devices, the iOS Simulator and Android. The compiler emits a native application object. The generated project includes the platform shell, the local Canvas renderer and the build script.
Generate a project
Install the full SDK, including xu-phone. The source directory must contain a xu.xun manifest. Run these commands from the root of the Xu 0.13.1 source tree. Choose a fresh output directory for each build.
xu build examples/phone_gallery --phone --target ios-simulator-arm64 --bundle-id org.example.gallery -o build/gallery-sim
xu build examples/phone_gallery --phone --target ios-arm64 --bundle-id org.example.gallery -o build/gallery-ios
xu build examples/phone_gallery --phone --target android-arm64 --bundle-id org.example.gallery -o build/gallery-android
# Native SDL GPU mobile game profile (uses #app resource packaging)
xu build examples/phone_game --phone --phone-profile game --target ios-simulator-arm64 --bundle-id org.example.game -o build/game-sim
xu build examples/phone_game --phone --phone-profile game --target android-arm64 --bundle-id org.example.game -o build/game-android
The generated projects contain the host sources and compiled object. To pick up Xu source changes, generate a fresh project before invoking the platform build.
If you keep several SDK installations, ensure that xu --version reports 0.13.1 and that any XU_ROOT and XU_STDLIB_ROOT overrides point to the same SDK.
Build on the target toolchain
- iOS Simulator. On macOS with Xcode, run
bash build/gallery-sim/build.sh. With an ARM64 simulator booted, usexcrun simctl install booted build/gallery-sim/build/XuPhone.app. The host targets iOS 16.4 or later. - iOS devices. Use the generated device project with a matching signing identity, provisioning profile and entitlements. Set
CODE_SIGN_IDENTITY,PROVISIONING_PROFILEandCODE_SIGN_ENTITLEMENTSfor its build script. - Android. Run
bash build/gallery-android/build.shwithANDROID_HOMEandJAVA_HOMEset. Install JDK 17 or later and Android SDK componentsplatforms;android-35,build-tools;35.0.0,ndk;27.2.12479018andcmake;3.22.1. The script producesbuild/gallery-android/build/XuPhone-debug.apk. The minimum Android API level is 26.
Draw and handle input
Use one root ui.Window, attach #ui/draw, and record complete frames after EV_CANVAS_READY. The host renders frames in a local system WebView Canvas. Application logic runs as native ARM64 code.
Read phone.host_insets() and pass them to phone.scaffold_with to keep controls clear of safe areas and the keyboard. The mobile kit provides routes, scrolling and pull-to-refresh, native IME text editing, haptics and clipboard integration. See the #ui/phone API, the #app API, and the gallery / game examples.
The mobile profile uses one window. It omits desktop menus, dialogs, embedded WebView controls, offscreen surfaces and per-control accessibility semantics. Release checks covered project generation and ARM64 object formats. Device and app-store acceptance remain separate platform tests. Host requirements and limits