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
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ extension Target {

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

static func rxCocoaRuntime() -> [Target] {
#if os(Linux)
#if os(Linux) || os(Android)
return []
#else
return [.rxTarget(name: "RxCocoaRuntime", dependencies: ["RxSwift"])]
Expand Down
4 changes: 2 additions & 2 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ extension Target {

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

static func rxCocoaRuntime() -> [Target] {
#if os(Linux)
#if os(Linux) || os(Android)
return []
#else
return [.rxTarget(name: "RxCocoaRuntime", dependencies: ["RxSwift"])]
Expand Down
32 changes: 32 additions & 0 deletions Platform/Platform.Android.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Platform.Android.swift
// Platform
//
// Created by Jake Prickett on 8/24/25.
// Copyright © 2025 Krunoslav Zaher. All rights reserved.
//

#if os(Android)

import Foundation

extension Thread {

static func setThreadLocalStorageValue<T: AnyObject>(_ value: T?, forKey key: String) {
if let newValue = value {
Thread.current.threadDictionary[key] = newValue
}
else {
Thread.current.threadDictionary[key] = nil
}
}

static func getThreadLocalStorageValueForKey<T: AnyObject>(_ key: String) -> T? {
let currentThread = Thread.current
let threadDictionary = currentThread.threadDictionary

return threadDictionary[key] as? T
}
}

#endif
1 change: 1 addition & 0 deletions RxBlocking/Platform/Platform.Android.swift
4 changes: 2 additions & 2 deletions RxBlocking/RunLoopLock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import CoreFoundation
import Foundation
import RxSwift

#if os(Linux)
#if os(Linux) || os(Android)
import Foundation
let runLoopMode: RunLoop.Mode = .default
let runLoopModeRaw: CFString = unsafeBitCast(runLoopMode.rawValue._bridgeToObjectiveC(), to: CFString.self)
Expand Down Expand Up @@ -61,7 +61,7 @@ final class RunLoopLock {
fatalError("Run can be only called once")
}
if let timeout = self.timeout {
#if os(Linux)
#if os(Linux) || os(Android)
let runLoopResult = CFRunLoopRunInMode(runLoopModeRaw, timeout, false)
#else
let runLoopResult = CFRunLoopRunInMode(runLoopMode, timeout, false)
Expand Down
4 changes: 2 additions & 2 deletions RxCocoa/Common/DelegateProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//

#if !os(Linux)
#if !os(Linux) && !os(Android)

import RxSwift
#if SWIFT_PACKAGE && !os(Linux)
#if SWIFT_PACKAGE && !os(Linux) && !os(Android)
import RxCocoaRuntime
#endif

Expand Down
2 changes: 1 addition & 1 deletion RxCocoa/Common/DelegateProxyType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//

#if !os(Linux)
#if !os(Linux) && !os(Android)

import Foundation
import RxSwift
Expand Down
4 changes: 2 additions & 2 deletions RxCocoa/Common/RxCocoaObjCRuntimeError+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
//

#if SWIFT_PACKAGE && !DISABLE_SWIZZLING && !os(Linux)
#if SWIFT_PACKAGE && !DISABLE_SWIZZLING && !os(Linux) && !os(Android)
import RxCocoaRuntime
#endif

#if !DISABLE_SWIZZLING && !os(Linux)
#if !DISABLE_SWIZZLING && !os(Linux) && !os(Android)
/// RxCocoa ObjC runtime interception mechanism.
public enum RxCocoaInterceptionMechanism {
/// Unknown message interception mechanism.
Expand Down
2 changes: 1 addition & 1 deletion RxCocoa/Foundation/KVORepresentable+CoreGraphics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//

#if !os(Linux)
#if !os(Linux) && !os(Android)

import RxSwift
import CoreGraphics
Expand Down
4 changes: 2 additions & 2 deletions RxCocoa/Foundation/NSObject+Rx+KVORepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//

#if !os(Linux)
#if !os(Linux) && !os(Android)

import Foundation
import RxSwift
Expand Down Expand Up @@ -42,7 +42,7 @@ extension Reactive where Base: NSObject {
}
}

#if !DISABLE_SWIZZLING && !os(Linux)
#if !DISABLE_SWIZZLING && !os(Linux) && !os(Android)
// KVO
extension Reactive where Base: NSObject {
/**
Expand Down
2 changes: 1 addition & 1 deletion RxCocoa/Foundation/NSObject+Rx+RawRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//

#if !os(Linux)
#if !os(Linux) && !os(Android)

import RxSwift

Expand Down
16 changes: 8 additions & 8 deletions RxCocoa/Foundation/NSObject+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//

#if !os(Linux)
#if !os(Linux) && !os(Android)

import Foundation
import RxSwift
#if SWIFT_PACKAGE && !DISABLE_SWIZZLING && !os(Linux)
import RxCocoaRuntime
#endif

#if !DISABLE_SWIZZLING && !os(Linux)
#if !DISABLE_SWIZZLING && !os(Linux) && !os(Android)
private var deallocatingSubjectTriggerContext: UInt8 = 0
private var deallocatingSubjectContext: UInt8 = 0
#endif
private var deallocatedSubjectTriggerContext: UInt8 = 0
private var deallocatedSubjectContext: UInt8 = 0

#if !os(Linux)
#if !os(Linux) && !os(Android)

/**
KVO is a tricky mechanism.
Expand Down Expand Up @@ -95,7 +95,7 @@ extension Reactive where Base: NSObject {

#endif

#if !DISABLE_SWIZZLING && !os(Linux)
#if !DISABLE_SWIZZLING && !os(Linux) && !os(Android)
// KVO
extension Reactive where Base: NSObject {
/**
Expand Down Expand Up @@ -144,7 +144,7 @@ extension Reactive where Base: AnyObject {
}
}

#if !DISABLE_SWIZZLING && !os(Linux)
#if !DISABLE_SWIZZLING && !os(Linux) && !os(Android)

/**
Observable sequence of message arguments that completes when object is deallocated.
Expand Down Expand Up @@ -264,7 +264,7 @@ extension Reactive where Base: AnyObject {

// MARK: Message interceptors

#if !DISABLE_SWIZZLING && !os(Linux)
#if !DISABLE_SWIZZLING && !os(Linux) && !os(Android)

private protocol MessageInterceptorSubject: AnyObject {
init()
Expand Down Expand Up @@ -349,7 +349,7 @@ private final class DeallocObservable {

// MARK: KVO

#if !os(Linux)
#if !os(Linux) && !os(Android)

private protocol KVOObservableProtocol {
var target: AnyObject { get }
Expand Down Expand Up @@ -438,7 +438,7 @@ private extension KeyValueObservingOptions {

#endif

#if !DISABLE_SWIZZLING && !os(Linux)
#if !DISABLE_SWIZZLING && !os(Linux) && !os(Android)

private func observeWeaklyKeyPathFor(_ target: NSObject, keyPath: String, options: KeyValueObservingOptions) -> Observable<AnyObject?> {
let components = keyPath.components(separatedBy: ".").filter { $0 != "self" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2021 Krunoslav Zaher. All rights reserved.
//

#if swift(>=5.6) && canImport(_Concurrency) && !os(Linux)
#if swift(>=5.6) && canImport(_Concurrency) && !os(Linux) && !os(Android)
import Foundation

// MARK: - Shared Sequence
Expand Down
1 change: 1 addition & 0 deletions RxSwift/Platform/Platform.Android.swift
2 changes: 1 addition & 1 deletion RxSwift/RxMutableBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//

#if os(Linux)
#if os(Linux) || os(Android)
/// As Swift 5 was released, A patch to `Thread` for Linux
/// changed `threadDictionary` to a `NSMutableDictionary` instead of
/// a `Dictionary<String, Any>`: https://github.com/apple/swift-corelibs-foundation/pull/1762/files
Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Schedulers/CurrentThreadScheduler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Dispatch
import Foundation

#if os(Linux)
#if os(Linux) || os(Android)
fileprivate enum CurrentThreadSchedulerQueueKey {
fileprivate static let instance = "RxSwift.CurrentThreadScheduler.Queue"
}
Expand Down
1 change: 1 addition & 0 deletions Sources/AllTestz/Platform.Android.swift
1 change: 1 addition & 0 deletions Sources/RxBlocking/Platform.Android.swift
1 change: 1 addition & 0 deletions Sources/RxSwift/Platform.Android.swift
1 change: 1 addition & 0 deletions Tests/Platform/Platform.Android.swift
1 change: 1 addition & 0 deletions scripts/validate-headers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ let excludePaths = [
"AllTestz/main.swift",
"Platform/AtomicInt.swift",
"Platform/Platform.Linux.swift",
"Platform/Platform.Android.swift",
"Platform/Platform.Darwin.swift",
"Platform/RecursiveLock.swift",
"Platform/DataStructures/Bag.swift",
Expand Down