Android XML to Compose and SwiftUI
Constructing user interfaces (UIs) is one of the most resource-intensive tasks in mobile development, often consuming more than half of overall effort. Although declarative frameworks such as Jetpack Compose (Android) and SwiftUI (iOS) have become mainstream, most Android apps still rely on legacy XML-based layouts.
Migrating these UIs to declarative paradigms is essential for maintainability and cross-platform reuse, but manual migration is costly, error-prone, and difficult to scale.
We present GUIMigrator, a semantics-preserving framework that automates the migration of Android XML-based UIs to Jetpack Compose and SwiftUI.
Key features:
- Semantic UI Transpiler (SUT): abstracts layout structures and resource semantics from legacy XML.
- Cross-platform consistency: systematically re-expresses semantics using idioms of Compose and SwiftUI.
- Deterministic yet extensible design: separates semantic interpretation from platform realization, avoiding unpredictability of purely generative approaches.
Evaluation on 31 open-source apps across ten domains shows:
- High migration completeness and visual similarity (Compose: 82%, SwiftUI: 78%).
- Outperforms GPT-4 baseline in structural fidelity.
- Reduces manual development effort by >90%.
These results demonstrate that GUIMigrator is a practical and effective solution for reusing Android UIs across modern declarative frameworks.
| Directory / Module | Description |
|---|---|
| datasets/ | Experimental datasets for evaluation. |
| ➤ business/ | Result data, including transpiled UI files (.swiftui, .kt, etc.). |
| ➤ communication/ | Domain-specific datasets (e.g., communication apps). |
| ➤ tools/ | Supporting scripts/tools for preprocessing and evaluation. |
| src/ | Core project source code. |
| ➤ entity/ | Source code structure representations (projects, layouts, resources, etc.). |
| ➤ utils/ | Common utilities (logging, file operations, etc.). |
| ➤ service/ | Core services for transpilation. |
| • parser/ | Parser for Android XML UI elements (layouts, views, attributes). |
| • rule/ | Transpilation rules for mapping XML to Compose/SwiftUI. |
| • transpiler/ | Logic for source analysis and transpilation process. |
| test/ | Test cases and evaluation scripts. |
| resources/ | Project configuration files (e.g., scanned Android app projects). |
-
RQ1: Migration Quality
To what extent does GUIMigrator preserve the visual fidelity and structural semantics of the original UI? -
RQ2: Migration Effectiveness
How many UI elements and attributes can GUIMigrator successfully migrate across diverse applications? -
RQ3: Development Effort Reduction
How much manual engineering effort can be saved compared to rebuilding UIs from scratch? -
RQ4: Migration Performance
What is the runtime overhead of the migration process in terms of efficiency and scalability?
Complete dataset:please refer to datasets directory.
The sources of Android applications (Github 9.9k ★):
open-source-android-apps
Here you can find all the source code files for the projects mentioned in the paper.
- Visual similarity: Compose 82%, SwiftUI 78%
- Structural fidelity: Higher than GPT-4 baseline
- Effort reduction: >90% less manual work
- Performance: Migration completes in seconds per layout
Results of UI migration across ten domains. Metrics include the number and proportion of successfully migrated XML files (XML), layouts (Layouts), and views (Views), together with the number of syntax errors in the generated code (Errors).
Comparative results of UI migration effectiveness. We report Code Relative Change (CRC), Code Token Change (CTC), and Structural Similarity Index (SSIM). Baseline uses GPT-4, compared with GUIMigrator.
Supplement parameter configurations in the task.properties file, including Android app file paths.
You need to locate the task.properties file in the src/main/resources directory, and then set the resourcePath to
the full path of the res directory of the Android app you wish to migrate.
The tool will automatically parse and migrate UI resources, layouts, and views from the res directory.
Execute the Main class:
Navigate to the main directory:
cd src/main/java
Open Main.java in your IDE.
Run the Main class.
This will transpile Android XML-based UI elements into Jetpack Compose and SwiftUI code.
this process will transpile Android UI elements.
📌 Tips
Ensure the task.properties file is configured correctly before running.
The transpiled files will be stored under the output directory specified in the configuration.
Check the logs for warnings (e.g., unmapped UI attributes).

