Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ let openCombineShimTarget: Target = .target(
dependencies: [
"OpenCombine",
.target(name: "OpenCombineDispatch",
condition: .when(platforms: supportedPlatforms.except([.wasi]))),
condition: .when(platforms: supportedPlatforms.except([.wasi, .android]))),
.target(name: "OpenCombineFoundation",
condition: .when(platforms: supportedPlatforms.except([.wasi]))),
condition: .when(platforms: supportedPlatforms.except([.wasi, .android]))),
]
)
let openCombineTarget: Target = .target(
name: "OpenCombine",
dependencies: [
.target(
name: "COpenCombineHelpers",
condition: .when(platforms: supportedPlatforms.except([.wasi]))
condition: .when(platforms: supportedPlatforms.except([.wasi, .android]))
),
],
exclude: [
Expand All @@ -53,7 +53,7 @@ let openCombineFoundationTarget: Target = .target(
"OpenCombine",
.target(
name: "COpenCombineHelpers",
condition: .when(platforms: supportedPlatforms.except([.wasi]))
condition: .when(platforms: supportedPlatforms.except([.wasi, .android]))
),
]
)
Expand All @@ -66,9 +66,9 @@ let openCombineTestsTarget: Target = .testTarget(
dependencies: [
"OpenCombine",
.target(name: "OpenCombineDispatch",
condition: .when(platforms: supportedPlatforms.except([.wasi]))),
condition: .when(platforms: supportedPlatforms.except([.wasi, .android]))),
.target(name: "OpenCombineFoundation",
condition: .when(platforms: supportedPlatforms.except([.wasi]))),
condition: .when(platforms: supportedPlatforms.except([.wasi, .android]))),
],
swiftSettings: [
.unsafeFlags(["-enable-testing"]),
Expand All @@ -90,8 +90,7 @@ let package = Package(
openCombineFoundationTarget,
openCombineDispatchTarget,
openCombineTestsTarget,
],
cxxLanguageStandard: .cxx17
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

LGTM except for this change. Could you elaborate on why this change is necessary?

Copy link
Author

@colemancda colemancda Jun 18, 2025

Choose a reason for hiding this comment

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

There seems to be some CPP interop issue with Android when not using the default setting.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@colemancda Thank you for the explanation. However, I don't think relying on default settings is a good approach as it may introduce maintenance burden for future upgrades and it also breaks other platform's build currently (See the failure CI - https://github.com/OpenSwiftUIProject/OpenCombine/actions/runs/15523371994/job/44321270577?pr=22).

Here are my suggestions:

  • Test different cxxLanguageStandard explicitly: Could you test the Android build environment with different explicit cxxLanguageStandard values to determine which specific setting works? We can then use different explicit standards for different OS platforms if needed. If a higher standard is required, we can also upgrade directly and adapt the code accordingly.
  • Share the specific build errors: Could you please share the actual error messages you're encountering with .cxx17? This would help us determine if we can stick with a unified cxxLanguageStandard (e.g., .cxx17) and handle the compatibility at the code level instead.
  • Consider adding Android CI workflow: I'm not familiar with the current Android build environment setup. If possible, would you mind also adding an Android CI build workflow? This would help us catch such cross-platform issues earlier and ensure better compatibility going forward.

Relying on implicit defaults makes the build configuration less predictable and harder to maintain across Swift toolchain versions. Let's work together to find a solution that uses explicit settings while maintaining Android compatibility.

)

// MARK: Helpers
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenCombine/CombineIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@_implementationOnly import COpenCombineHelpers
#endif

#if os(WASI)
#if os(WASI) || os(Android)
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

The fallback for generating combine identifiers on Android is non-atomic and not thread-safe, which may produce duplicate IDs under concurrent use. Consider using an atomic counter or lock to ensure uniqueness.

Copilot uses AI. Check for mistakes.

private var __identifier: UInt64 = 0

internal func __nextCombineIdentifier() -> UInt64 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenCombine/Helpers/Locking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@_implementationOnly import COpenCombineHelpers
#endif

#if os(WASI)
#if os(WASI) || os(Android)
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

Stubbing out the lock on Android removes all mutual exclusion, which can lead to data races in multithreaded contexts. Consider providing a real lock implementation or documenting that this platform build is not thread-safe.

Suggested change
#if os(WASI) || os(Android)
#if os(WASI)
// Note: The WASI platform is assumed to run in a single-threaded environment.
// This implementation is not thread-safe.

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

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

This will only be used on main thread in any case.

internal struct __UnfairLock { // swiftlint:disable:this type_name
internal static func allocate() -> UnfairLock { return .init() }
internal func lock() {}
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenCombine/Publishers/Publishers.Breakpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Sergej Jaskiewicz on 03.12.2019.
//

#if !os(WASI)
#if !(os(WASI) || os(Android))

#if canImport(COpenCombineHelpers)
@_implementationOnly import COpenCombineHelpers
Expand Down
Loading