Skip to content

[Proposal] Android support - #2

Draft
gevartosky wants to merge 5 commits into
patch-release:mainfrom
gevartosky:android-prototype
Draft

gevartosky wants to merge 5 commits into
patch-release:mainfrom
gevartosky:android-prototype

Conversation

@gevartosky

Copy link
Copy Markdown

Hi

I wanted to propose support for Swift on Android as adoption has been growing and I really believe Patch would come ahead if such support becomes a reality.

I'm personally excited for Patch and it would be a great fit for my client application.

You can find a deeper dive of this proposal in proposals/android-support.md, but in essence I believe we could split the package into a Core package + Platform specific packages. This way we can initially support swift business logic on Android while UI and Apple specific API stay on a separate packages.

I'm leaving the PR in Draft for now and I'm happy to take any feedback and help with anything necessary.

gregorio-gt and others added 5 commits October 15, 2026 20:29
Make the whole package and the PatchSDKTests bundle compile and link for
aarch64-unknown-linux-android28 (Swift SDK for Android / `skip android build`),
with no behaviour change on Apple platforms.

- Vendor Google's reference Brotli decoder (v1.2.0, MIT) as CBrotliDec and
  rewrite Brotli.swift on its streaming API, replacing Apple's Compression
  framework. Truncated streams and trailing bytes are now rejected.
- Vendor the reference libbzip2 (1.0.8, sourceware.org) as the CBZ2 target,
  replacing the system-library shim; the Android NDK ships no libbz2.
- Use apple/swift-crypto for SHA-256 where CryptoKit is unavailable (linked
  only on Android/Linux).
- Import FoundationNetworking where URLSession/URLRequest are used.
- Guard Darwin-only APIs: CoreFoundation number checks, Combine in
  UpdateState, ProcessInfo thermal/low-power, ObjC swizzles, Handoff.
- Do not register KeychainBridge or relative_date_format off Apple
  platforms: a module importing them fails to instantiate and falls back,
  instead of pretending to work.
- Tests that exercise Apple-only code use the same guard as that code.
- Add proposals/android-support.md describing the approach and options.

Verified: macOS suite 1031 tests, 0 failures; iOS Simulator build; Android
build of all targets and the test bundle. Not yet run on a device/emulator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`skip android test` on an Android 17 arm64 emulator: 771 tests, 0 failures,
6 skipped (the same skips as on macOS).

FoundationNetworking on Android rejects file:// URLs with
NSURLErrorUnsupportedURL, so FileDownloadBridge.syncDownload now copies
local files directly off Apple platforms. Apple platforms keep using
URLSession. HTTPS through URLSession was verified to work on the emulator.

Update the Android proposal with the device results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add an `android` job that cross-compiles the package with the official
Swift SDK for Android (6.4) and runs PatchSDKTests on an emulator via
skiptools/swift-android-action, alongside the existing macOS + iOS job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Package.resolved: restore main's lockfile. The branch had pinned
  swift-crypto 5.0.0 and swift-asn1 1.7.3 (resolved with Swift 6.4), which
  need tools 6.1/6.2 and broke `swift build` on the macOS job's Swift 6.0.3.
  Left unpinned, SwiftPM picks versions compatible with the toolchain, as it
  already does for swift-nio/swift-log on main.
- Android job: use swift-version "6.4.0". "6.4" maps to a download URL that
  does not exist (curl exit 22).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Swift 6.4's swift-build backend names the test resource bundle
`PatchSDK_PatchSDKTests.bundle`, while skiptools/swift-android-action only
copies `*.resources`, so the first fixture-loading test hit
"unable to find bundle named PatchSDK_PatchSDKTests". Pass the .bundle via
the action's copy-files input.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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