XU XUv0.16.0

用 Xu 構建移動應用

Xu 0.16.0 可生成 iOS 真機、iOS 模擬器和 Android 的 ARM64 應用專案。編譯器輸出原生應用目標檔案,生成目錄同時包含平臺宿主、本地 Canvas 渲染器和構建指令碼。

生成專案

安裝包含 xu-phone 的完整 SDK。輸入目錄必須包含 xu.xun。在 Xu 0.16.0 原始碼樹根目錄執行以下命令,每次選用一個尚不存在的輸出目錄。

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.16.0,並將環境中的 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 目標檔案格式,真機和應用商店驗收需另行測試。宿主要求與限制