Porting Declarative UI to HarmonyOS: A Heuristic-guided LLM Approach

📅 2026-06-05
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the challenges of language unfamiliarity and syntactic ambiguity in automatically migrating declarative UI code from Android (Jetpack Compose) and iOS (SwiftUI) to HarmonyOS ArkUI. To this end, the authors propose ArkTrans, a novel approach that synergistically combines heuristic skeleton guidance with empirical post-repair rules. Specifically, ArkTrans first constructs an ArkUI skeleton from metadata to steer large language models toward generating an initial translation, then applies pattern-matching-driven post-repair rules to correct syntactic errors. Evaluated on 100 real-world UI pages, ArkTrans achieves a compilable rate of 90.67% while preserving high visual fidelity, substantially outperforming existing strategies based on direct or single-shot prompting with large language models. This study represents the first demonstration of high-quality cross-platform migration for declarative UI frameworks.
📝 Abstract
As an emerging operating system, HarmonyOS has a significant demand for software migration from platforms such as Android and iOS, where the User Interface (UI) translation accounts for a critical link. However, the latest UI development has shifted to declarative paradigms, e.g., Kotlin Jetpack Compose (KJC) for Android, SwiftUI for iOS, and ArkUI for HarmonyOS, rendering prior translation approaches inapplicable, as they target either backend logic or legacy imperative UIs. As such, this paper targets ArkUI and proposes an automatic translation approach, namely ArkTrans, to port UI files from Android and iOS to HarmonyOS. ArkTrans overcomes two salient challenges during the translation: (1) Programming Language (PL) unfamiliarity, and (2) severe syntactic chaos. Towards the first challenge, ArkTrans heuristically constructs ArkUI skeletons by extracting metadata from source PL, thereby guiding LLMs' initial translation. As for the second challenge, ArkTrans executes empirically revealed post-fixing rules via pattern matching to repair most of the remaining syntactic errors. To examine the effectiveness of ArkTrans, we construct a 100-sample parallel UI page translation benchmark from KJC/SwiftUI to ArkUI at the file level. Extensive experiments demonstrate that LLMs with direct/one-shot prompting cannot translate a single compilable UI page. In contrast, at most 90.67\% ArkTrans-translated files can be successfully compiled with high visual fidelity.
Problem

Research questions and friction points this paper is trying to address.

Declarative UI
HarmonyOS
UI migration
ArkUI
Cross-platform translation
Innovation

Methods, ideas, or system contributions that make the work stand out.

declarative UI translation
HarmonyOS ArkUI
LLM-guided code migration
heuristic skeleton construction
syntax error post-fixing