Skip to content

Add Android support - #222

Open
finagolfin wants to merge 1 commit into
apple:mainfrom
finagolfin:droid
Open

finagolfin wants to merge 1 commit into
apple:mainfrom
finagolfin:droid

Conversation

@finagolfin

Copy link
Copy Markdown

This package now compiles and all tests passed natively on Android built against API 24 with a Sep. 21 trunk snapshot toolchain and apple/swift-tls#23 applied to that dependency, though with the -Xswiftc -O flag added to work around swiftlang/swift#92886.

internal import Logging
#elseif canImport(Android)
import Android
internal import Logging

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

All these imports were added by a regex substitution, then manually reviewed.

Comment thread Sources/SwiftNetwork/System/Darwin/DarwinResources.swift
#if os(Linux) || os(Android)
#if canImport(Glibc)
import Glibc
internal import SwiftNetworkLinuxShim

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This linux shim works on Android, but I removed it since it's unneeded.

@finagolfin

Copy link
Copy Markdown
Author

Rebased, added Android to CI, and made a formatting change to one file that the CI check wanted.

@rpaulo

rpaulo commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Looks like we need to fix this CI build error:

find: ‘/home/runner/work/swift-network-evolution/swift-network-evolution/.build/out/Products/Debug-android-x86_64’: No such file or directory
INFO         | Boot completed in 23943 ms
INFO         | Increasing screen off timeout, logcat buffer size to 2M.
WARNING      | adb command '/usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell cmd window set-ignore-orientation-request true ' failed: 'Unknown command: set-ignore-orientation-request'

I'm not familiar with Android, but do you know what's going on?

@finagolfin

Copy link
Copy Markdown
Author

Oh, didn't notice that you are switching back to the native build system for the nightlies on CI, any reason you still have that? That is causing the above Android error for the 6.4.x nightlies, as the 6.4 release works fine for Android, where that flag is not applied. The trunk build hangs, as do all the other builds using the linux toolchain right now because of the compiler issue I linked.

@rpaulo

rpaulo commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Oh, didn't notice that you are switching back to the native build system for the nightlies on CI, any reason you still have that? That is causing the above Android error for the 6.4.x nightlies, as the 6.4 release works fine for Android, where that flag is not applied. The trunk build hangs, as do all the other builds using the linux toolchain right now because of the compiler issue I linked.

Are you saying that nightly-6.4 doesn't work on Android? If that's the case, we can disable it for now in your CI changes.

@finagolfin

Copy link
Copy Markdown
Author

Are you saying that nightly-6.4 doesn't work on Android? If that's the case, we can disable it for now in your CI changes.

No, the issue is that the official GitHub workflows now only expect the Android SDK to be used with the swiftbuild build system, so they only look in that internal build directory for the test runners. I find it strange that you are still using the native build system for the nightlies alone on the CI here, do you know why that is?

@rpaulo

rpaulo commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

I think the --build-system native flag was to work around an issue on 6.5 (maybe). I think it's worth removing it now to see if it's still needed.

@finagolfin

Copy link
Copy Markdown
Author

OK, will try that here and see.

Comment thread .github/workflows/main.yml
@rpaulo rpaulo added the 🆕 semver/minor Adds new public API. label Oct 6, 2026
@rpaulo rpaulo added 🔨 semver/patch No public API change. and removed 🆕 semver/minor Adds new public API. labels Oct 6, 2026
Comment thread .github/workflows/pull_request.yml Outdated
@finagolfin

Copy link
Copy Markdown
Author

Hmm, most CI failing in this test that was added yesterday, some subsequent pull broke it?

@rpaulo

rpaulo commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Hmm, most CI failing in this test that was added yesterday, some subsequent pull broke it?

It's fixed now. Could you please rebase?

@finagolfin

Copy link
Copy Markdown
Author

@rpaulo, rebased, please run CI.

@finagolfin

Copy link
Copy Markdown
Author

The last rebase picked up a new linux/mac-only logging method: added it for Android and checked to make sure this branch builds on Android locally before updating now.

@finagolfin

Copy link
Copy Markdown
Author

Alright, all non-trunk builds are passing now, including the nightly 6.4.x Android SDK snapshots once I removed the change to the native build system. How about we get the first commit here in for Android support, then I will submit a separate CI-only pull to clean up those workflows for all platforms?

Comment thread .github/workflows/pull_request.yml Outdated

@rpaulo rpaulo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes look good, minor small nits. Probably wait for #226 before rebasing.

@finagolfin

Copy link
Copy Markdown
Author

No need to wait on #226, as all trunk builds fail because of the trunk compiler regression anyway.

@agnosticdev agnosticdev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants