Skip to content

Support building natively on Android (bionic) hosts - #238

Open
hpr wants to merge 1 commit into
xtool-org:mainfrom
hpr:android-support
Open

hpr wants to merge 1 commit into
xtool-org:mainfrom
hpr:android-support

Conversation

@hpr

@hpr hpr commented Aug 12, 2026

Copy link
Copy Markdown

This makes xtool build and run natively on Android with the Swift Android toolchain (tested on aarch64 Termux). All changes are additive platform guards; no behavior change on existing platforms.

  • Package.swift: enable the Subprocess, AsyncHTTPClient, OpenAPIAsyncHTTPClient, WebSocketKit, and XADI dependencies on Android, matching Linux (Package.resolved updated accordingly).
  • XKit: use the AsyncHTTPClient-based HTTPClient on Android too — the URLSession-based client needs Darwin-only URLSessionWebSocketTask. Also, bionic's FILE is an incomplete type, so stdoutSafe is an OpaquePointer there.
  • XToolSupport / XUtils: import the Android overlay where needed (SIG_IGN, flock, errno); bionic marks signal() warn_unused_result.

Companion PRs for the dependencies, required for an end-to-end Android build:

One remaining quirk when building on-device: SwiftPM doesn't pass swift-subprocess' _SubprocessCShims module map to dependents, so I had to build with -Xswiftc -Xcc -Xswiftc -fmodule-map-file=.../_SubprocessCShims/include/module.modulemap. This looks like a SwiftPM/Android toolchain issue rather than something xtool should work around, but I'm happy to add a note to the docs if you'd like.

Summary by CodeRabbit

  • New Features

    • Added support for building and running xtool on Android ARM64 devices and emulators.
    • Added Android development and release build workflows, including Docker-based tooling.
    • Extended supported networking and subprocess functionality to Android.
    • Added Android smoke testing with emulator validation.
  • Documentation

    • Added instructions for Android development, builds, and runtime checks.
  • Chores

    • Added automated Android debug builds and manual workflow triggers.
    • Excluded Android build artifacts from version control and Docker contexts.

@kabiroberai kabiroberai left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Wanna add a CI job as well? Should be able to cross compile on Linux with the Swift SDK.

@hpr

hpr commented Aug 17, 2026

Copy link
Copy Markdown
Author

Nice! Wanna add a CI job as well? Should be able to cross compile on Linux with the Swift SDK.

@kabiroberai Added CI build green at https://github.com/hpr/xtool/actions/runs/32047498390, but it depends on xtool-org/xtool-core#2 and saagarjha/unxip#41.

@kabiroberai

Copy link
Copy Markdown
Member

Tagged the xtool-core commit. PR looks good now, once saagarjha/unxip#41 lands (I left another comment there about a fix you'll need to make for GNU/Linux)

@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 00580290-8d5f-4855-97ae-51417aa2f3ba

📥 Commits

Reviewing files that changed from the base of the PR and between f0ef415 and 8dbb966.

⛔ Files ignored due to path filters (1)
  • Package.resolved is excluded by !**/Package.resolved
📒 Files selected for processing (17)
  • .dockerignore
  • .github/workflows/build.yml
  • .gitignore
  • Android/README.md
  • Android/build-deps.sh
  • Android/build.sh
  • Android/defs.sh
  • Android/smoke-test.sh
  • Dockerfile
  • Makefile
  • Package.swift
  • Sources/XKit/HTTPClientProtocol/AsyncHTTPClient+HTTP.swift
  • Sources/XKit/HTTPClientProtocol/URLSession+HTTP.swift
  • Sources/XKit/Utilities/CHelpers.swift
  • Sources/XToolSupport/XTool.swift
  • Sources/XUtils/System+Utils.swift
  • docker-compose.yml
 __________________________________
< Pulling the bugs out of the hat. >
 ----------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@kabiroberai
kabiroberai force-pushed the android-support branch 3 times, most recently from 8dbb966 to f9f7eb3 Compare September 22, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants