diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 091f9d1..080c168 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ jobs: uses: skiptools/actions/.github/workflows/skip-framework.yml@v1 with: # disable export because there are currently problems with shared PCH module cache files with multi-module native export + runs-on: "['macos-15-intel', 'ubuntu-24.04']" run-export: false #run-local-tests: false diff --git a/Sources/SkipAndroidBridge/AndroidBridgeBootstrap.swift b/Sources/SkipAndroidBridge/AndroidBridgeBootstrap.swift index 089dfa6..d097587 100644 --- a/Sources/SkipAndroidBridge/AndroidBridgeBootstrap.swift +++ b/Sources/SkipAndroidBridge/AndroidBridgeBootstrap.swift @@ -16,6 +16,25 @@ import Foundation @_exported import AndroidLogging #elseif canImport(OSLog) @_exported import OSLog +#else +// e.g., for Linux define a local logging stub +class Logger { + let subsystem: String + let category: String + + init(subsystem: String, category: String) { + self.subsystem = subsystem + self.category = category + } + + func log(_ string: String) { + print("\(subsystem)/\(category): \(string)") + } + + func debug(_ string: String) { + print("\(subsystem)/\(category): \(string)") + } +} #endif #if canImport(AndroidLooper) @_exported import AndroidLooper @@ -127,7 +146,7 @@ private func bootstrapFileManagerProperties(filesDir: String, cacheDir: String) } // URL.applicationSupportDirectory exists in Darwin's Foundation but not in Android's Foundation -#if os(Android) +#if !canImport(Darwin) // SKIP @nobridge extension URL { public static var applicationSupportDirectory: URL { diff --git a/Sources/SkipAndroidBridge/AndroidBundle.swift b/Sources/SkipAndroidBridge/AndroidBundle.swift index c40ce31..3eda3d7 100644 --- a/Sources/SkipAndroidBridge/AndroidBundle.swift +++ b/Sources/SkipAndroidBridge/AndroidBundle.swift @@ -2,6 +2,10 @@ // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if os(Linux) +// Bundle subclass does not build on Linux due to https://github.com/swiftlang/swift-corelibs-foundation/issues/5108 +public typealias AndroidBundle = Foundation.Bundle +#else /// Override of native `Bundle` for Android that delegates to our `skip.foundation.Bundle` Kotlin object. open class AndroidBundle : Foundation.Bundle, @unchecked Sendable { #if os(Android) || ROBOLECTRIC @@ -304,6 +308,7 @@ open class AndroidBundle : Foundation.Bundle, @unchecked Sendable { } #endif } +#endif #if os(Android) || ROBOLECTRIC diff --git a/Sources/SkipAndroidBridgeSamples/SkipAndroidBridgeSamples.swift b/Sources/SkipAndroidBridgeSamples/SkipAndroidBridgeSamples.swift index c4b313e..045b422 100644 --- a/Sources/SkipAndroidBridgeSamples/SkipAndroidBridgeSamples.swift +++ b/Sources/SkipAndroidBridgeSamples/SkipAndroidBridgeSamples.swift @@ -39,6 +39,11 @@ public func setStringDefault(name: String, value: String?) { UserDefaults.standard.set(value, forKey: name) } +#if os(Linux) +// workaround for missing LocalizedStringResource on Linux +typealias LocalizedStringResource = AndroidLocalizedStringResource +#endif + public func localizedStringResourceLiteralKey() -> String { let literal: LocalizedStringResource = "literal" return literal.key diff --git a/Tests/SkipAndroidBridgeSamplesTests/XCSkipTests.swift b/Tests/SkipAndroidBridgeSamplesTests/XCSkipTests.swift index 45ef89e..1a19069 100644 --- a/Tests/SkipAndroidBridgeSamplesTests/XCSkipTests.swift +++ b/Tests/SkipAndroidBridgeSamplesTests/XCSkipTests.swift @@ -1,7 +1,7 @@ // Copyright 2024–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation -#if os(macOS) // Skip transpiled tests only run on macOS targets +#if os(macOS) || os(Linux) import SkipTest /// This test case will run the transpiled tests for the Skip module. diff --git a/Tests/SkipAndroidBridgeTests/XCSkipTests.swift b/Tests/SkipAndroidBridgeTests/XCSkipTests.swift index 45ef89e..1a19069 100644 --- a/Tests/SkipAndroidBridgeTests/XCSkipTests.swift +++ b/Tests/SkipAndroidBridgeTests/XCSkipTests.swift @@ -1,7 +1,7 @@ // Copyright 2024–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation -#if os(macOS) // Skip transpiled tests only run on macOS targets +#if os(macOS) || os(Linux) import SkipTest /// This test case will run the transpiled tests for the Skip module.