XU XUv0.13.1
EN

用 Xu 构建移动应用

Xu 0.13.1 可生成 iOS 真机、iOS 模拟器和 Android 的 ARM64 应用项目。编译器输出原生应用目标文件,生成目录同时包含平台宿主、本地 Canvas 渲染器和构建脚本。

生成项目

安装包含 xu-phone 的完整 SDK。输入目录必须包含 xu.xun。在 Xu 0.13.1 源码树根目录运行以下命令,每次选用一个尚不存在的输出目录。

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

# 原生 SDL GPU 移动游戏宿主模式(配合 #app 资源打包)
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

输出包含宿主源码和已编译的目标文件。修改 Xu 源码后,先重新生成项目,再运行平台构建脚本。

如果同时安装了多个 SDK,请确认 xu --version 显示 0.13.1,并将环境中的 XU_ROOT、XU_STDLIB_ROOT 指向同一套 SDK。

用平台工具链构建

绘制界面与处理输入

创建一个根 ui.Window,挂接 #ui/draw,收到 EV_CANVAS_READY 后录制完整帧。平台宿主在本地系统 WebView Canvas 绘制帧,应用逻辑以原生 ARM64 代码运行。

读取 phone.host_insets(),并将结果传入 phone.scaffold_with,避免控件被系统安全区和键盘遮挡。移动组件库还提供路由、滚动与下拉刷新、系统输入法文本编辑、触觉反馈及剪贴板集成。详见 #ui/phone API、#app API 以及界面示例 / 游戏示例。

移动宿主使用单窗口,桌面菜单和对话框、嵌入式 WebView 控件、离屏表面及逐控件无障碍语义超出当前范围。发布验证覆盖项目生成和 ARM64 目标文件格式,真机和应用商店验收需另行测试。宿主要求与限制