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
12 changes: 11 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,14 @@ jobs:
# steps:
# - uses: actions/checkout@v3
# - name: Run tests
# run: CI=1 ./scripts/all-tests.sh "Unix"
# run: CI=1 ./scripts/all-tests.sh "Unix"


linux:
name: "Test (Android)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Test Swift Package on Android"
uses: skiptools/swift-android-action@v2

54 changes: 34 additions & 20 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
// swift-tools-version:5.9

import PackageDescription
import Foundation

func targetsDarwin() -> Bool {
if (ProcessInfo.processInfo.environment["TARGET_OS_ANDROID"] ?? "0") != "0" {
// we are building for Android, and so Cocoa is not available
return false
}

#if !canImport(Darwin)
return false // Linux, Windows, etc.
#else
return true // macOS, iOS, etc.
#endif
}

let buildTests = false

Expand All @@ -25,29 +39,29 @@ extension Target {
}

extension Target {
static func rxCocoa() -> [Target] {
#if os(Linux)
return [.rxTarget(name: "RxCocoa", dependencies: ["RxSwift", "RxRelay"])]
#else
return [.rxTarget(name: "RxCocoa", dependencies: ["RxSwift", "RxRelay", "RxCocoaRuntime"])]
#endif
}
static func rxCocoa() -> [Target] {
if !targetsDarwin() {
return [.rxTarget(name: "RxCocoa", dependencies: ["RxSwift", "RxRelay"])]
} else {
return [.rxTarget(name: "RxCocoa", dependencies: ["RxSwift", "RxRelay", "RxCocoaRuntime"])]
}
}

static func rxCocoaRuntime() -> [Target] {
#if os(Linux)
return []
#else
return [.rxTarget(name: "RxCocoaRuntime", dependencies: ["RxSwift"])]
#endif
}
static func rxCocoaRuntime() -> [Target] {
if !targetsDarwin() {
return []
} else {
return [.rxTarget(name: "RxCocoaRuntime", dependencies: ["RxSwift"])]
}
}

static func allTests() -> [Target] {
if buildTests {
return [.target(name: "AllTestz", dependencies: ["RxSwift", "RxCocoa", "RxBlocking", "RxTest"])]
} else {
return []
static func allTests() -> [Target] {
if buildTests {
return [.target(name: "AllTestz", dependencies: ["RxSwift", "RxCocoa", "RxBlocking", "RxTest"])]
} else {
return []
}
}
}
}

let package = Package(
Expand Down