Skip to content

Commit 5734ad2

Browse files
authored
Fix compilation for < Swift 6.2, add CI for Xcode 16 (#2688)
1 parent 34e2c25 commit 5734ad2

File tree

262 files changed

+3769
-3723
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+3769
-3723
lines changed

.github/workflows/tests.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,23 @@ jobs:
2323
run: sudo xcode-select -s /Applications/Xcode_26.2.app
2424
- name: Run Tests
2525
run: CI=1 ./scripts/all-tests.sh "${{ matrix.environment }}"
26-
26+
27+
xcode16:
28+
name: "Xcode 16"
29+
runs-on: macos-15
30+
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
environment: [iOS, iOS-Example, Unix, watchOS, tvOS, SPM]
35+
36+
steps:
37+
- uses: actions/checkout@v3
38+
- name: Select Xcode 16
39+
run: sudo xcode-select -s /Applications/Xcode_16.4.app
40+
- name: Run Tests
41+
run: CI=1 ./scripts/all-tests.sh "${{ matrix.environment }}"
42+
2743
linux:
2844
name: "Build (Android)"
2945
runs-on: ubuntu-latest

.swiftformat

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
--ifdef no-indent
22
--wrap-arguments before-first
3-
--exclude Sources/AllTestz/main.swift,RxTest/HotObservable.swift,Tests/RxSwiftTests/BagTest.swift
3+
--commas inline
4+
--doc-comments preserve
5+
--exclude Sources/AllTestz/main.swift,RxTest/HotObservable.swift,Tests/RxSwiftTests/BagTest.swift

Package.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extension Product {
3434
if targetsDarwin {
3535
[
3636
.library(name: "RxCocoa", targets: ["RxCocoa"]),
37-
.library(name: "RxCocoa-Dynamic", type: .dynamic, targets: ["RxCocoa"]),
37+
.library(name: "RxCocoa-Dynamic", type: .dynamic, targets: ["RxCocoa"])
3838
]
3939
} else {
4040
[]
@@ -47,7 +47,7 @@ extension Target {
4747
.target(
4848
name: name,
4949
dependencies: dependencies,
50-
resources: [.copy("PrivacyInfo.xcprivacy")],
50+
resources: [.copy("PrivacyInfo.xcprivacy")]
5151
)
5252
}
5353
}
@@ -63,10 +63,10 @@ extension Target {
6363
dependencies: [
6464
"RxSwift",
6565
"RxRelay",
66-
.target(name: "RxCocoaRuntime", condition: .when(platforms: [.iOS, .macOS, .tvOS, .watchOS])),
66+
.target(name: "RxCocoaRuntime", condition: .when(platforms: [.iOS, .macOS, .tvOS, .watchOS]))
6767
],
68-
resources: [.copy("PrivacyInfo.xcprivacy")],
69-
),
68+
resources: [.copy("PrivacyInfo.xcprivacy")]
69+
)
7070
]
7171
}
7272
}
@@ -79,8 +79,8 @@ extension Target {
7979
.target(
8080
name: "RxCocoaRuntime",
8181
dependencies: ["RxSwift"],
82-
resources: [.copy("PrivacyInfo.xcprivacy")],
83-
),
82+
resources: [.copy("PrivacyInfo.xcprivacy")]
83+
)
8484
]
8585
}
8686
}
@@ -106,23 +106,23 @@ let package = Package(
106106
.library(name: "RxSwift-Dynamic", type: .dynamic, targets: ["RxSwift"]),
107107
.library(name: "RxRelay-Dynamic", type: .dynamic, targets: ["RxRelay"]),
108108
.library(name: "RxBlocking-Dynamic", type: .dynamic, targets: ["RxBlocking"]),
109-
.library(name: "RxTest-Dynamic", type: .dynamic, targets: ["RxTest"]),
109+
.library(name: "RxTest-Dynamic", type: .dynamic, targets: ["RxTest"])
110110
],
111111
Product.rxCocoaProducts(),
112-
Product.allTests(),
112+
Product.allTests()
113113
] as [[Product]]).flatMap(\.self),
114114
targets: ([
115115
[
116-
.rxTarget(name: "RxSwift", dependencies: []),
116+
.rxTarget(name: "RxSwift", dependencies: [])
117117
],
118118
Target.rxCocoa(),
119119
Target.rxCocoaRuntime(),
120120
[
121121
.rxTarget(name: "RxRelay", dependencies: ["RxSwift"]),
122122
.target(name: "RxBlocking", dependencies: ["RxSwift"]),
123-
.target(name: "RxTest", dependencies: ["RxSwift"]),
123+
.target(name: "RxTest", dependencies: ["RxSwift"])
124124
],
125-
Target.allTests(),
125+
Target.allTests()
126126
] as [[Target]]).flatMap(\.self),
127-
swiftLanguageVersions: [.v5],
127+
swiftLanguageVersions: [.v5]
128128
)

[email protected]

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extension Product {
3434
if targetsDarwin {
3535
[
3636
.library(name: "RxCocoa", targets: ["RxCocoa"]),
37-
.library(name: "RxCocoa-Dynamic", type: .dynamic, targets: ["RxCocoa"]),
37+
.library(name: "RxCocoa-Dynamic", type: .dynamic, targets: ["RxCocoa"])
3838
]
3939
} else {
4040
[]
@@ -63,10 +63,10 @@ extension Target {
6363
dependencies: [
6464
"RxSwift",
6565
"RxRelay",
66-
.target(name: "RxCocoaRuntime", condition: .when(platforms: [.iOS, .macOS, .tvOS, .watchOS, .visionOS])),
66+
.target(name: "RxCocoaRuntime", condition: .when(platforms: [.iOS, .macOS, .tvOS, .watchOS, .visionOS]))
6767
],
6868
resources: [.copy("PrivacyInfo.xcprivacy")]
69-
),
69+
)
7070
]
7171
}
7272
}
@@ -80,7 +80,7 @@ extension Target {
8080
name: "RxCocoaRuntime",
8181
dependencies: ["RxSwift"],
8282
resources: [.copy("PrivacyInfo.xcprivacy")]
83-
),
83+
)
8484
]
8585
}
8686
}
@@ -106,23 +106,23 @@ let package = Package(
106106
.library(name: "RxSwift-Dynamic", type: .dynamic, targets: ["RxSwift"]),
107107
.library(name: "RxRelay-Dynamic", type: .dynamic, targets: ["RxRelay"]),
108108
.library(name: "RxBlocking-Dynamic", type: .dynamic, targets: ["RxBlocking"]),
109-
.library(name: "RxTest-Dynamic", type: .dynamic, targets: ["RxTest"]),
109+
.library(name: "RxTest-Dynamic", type: .dynamic, targets: ["RxTest"])
110110
],
111111
Product.rxCocoaProducts(),
112-
Product.allTests(),
112+
Product.allTests()
113113
] as [[Product]]).flatMap(\.self),
114114
targets: ([
115115
[
116-
.rxTarget(name: "RxSwift", dependencies: []),
116+
.rxTarget(name: "RxSwift", dependencies: [])
117117
],
118118
Target.rxCocoa(),
119119
Target.rxCocoaRuntime(),
120120
[
121121
.rxTarget(name: "RxRelay", dependencies: ["RxSwift"]),
122122
.target(name: "RxBlocking", dependencies: ["RxSwift"]),
123-
.target(name: "RxTest", dependencies: ["RxSwift"]),
123+
.target(name: "RxTest", dependencies: ["RxSwift"])
124124
],
125-
Target.allTests(),
125+
Target.allTests()
126126
] as [[Target]]).flatMap(\.self),
127127
swiftLanguageVersions: [.v5]
128128
)

Rx.playground/Pages/Creating_and_Subscribing_to_Observables.xcplaygroundpage/Contents.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ example("generate") {
156156
Observable.generate(
157157
initialState: 0,
158158
condition: { $0 < 3 },
159-
iterate: { $0 + 1 },
159+
iterate: { $0 + 1 }
160160
)
161161
.subscribe(onNext: { print($0) })
162162
.disposed(by: disposeBag)

Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ example("filter") {
2222
Observable.of(
2323
"🐱", "🐰", "🐶",
2424
"🐸", "🐱", "🐰",
25-
"🐹", "🐸", "🐱",
25+
"🐹", "🐸", "🐱"
2626
)
2727
.filter {
2828
$0 == "🐱"

RxCocoa/Common/DelegateProxy.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@ private final class MessageDispatcher {
263263
fileprivate let selector: Selector
264264

265265
init(selector: Selector, delegateProxy _delegateProxy: DelegateProxy<some Any, some Any>) {
266+
#if swift(>=6.2)
266267
weak let weakDelegateProxy = _delegateProxy
268+
#else
269+
weak var weakDelegateProxy = _delegateProxy
270+
#endif
267271

268272
let dispatcher = PublishSubject<[Any]>()
269273
self.dispatcher = dispatcher

RxCocoa/Common/DelegateProxyType.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ public extension DelegateProxyType {
209209
/// - parameter onProxyForObject: Object that has `delegate` property.
210210
/// - returns: Disposable object that can be used to clear forward delegate.
211211
static func installForwardDelegate(_ forwardDelegate: Delegate, retainDelegate: Bool, onProxyForObject object: ParentObject) -> Disposable {
212+
#if swift(>=6.2)
212213
weak let weakForwardDelegate: AnyObject? = forwardDelegate as AnyObject
214+
#else
215+
weak var weakForwardDelegate: AnyObject? = forwardDelegate as AnyObject
216+
#endif
213217
let proxy = proxy(for: object)
214218

215219
assert(
@@ -218,7 +222,7 @@ public extension DelegateProxyType {
218222
"If you are ok with this, try to set delegate (data source) to `nil` in front of this operation.\n" +
219223
" This is the source object value: \(object)\n" +
220224
" This is the original delegate (data source) value: \(proxy.forwardToDelegate()!)\n" +
221-
"Hint: Maybe delegate was already set in xib or storyboard and now it's being overwritten in code.\n",
225+
"Hint: Maybe delegate was already set in xib or storyboard and now it's being overwritten in code.\n"
222226
)
223227

224228
proxy.setForwardToDelegate(forwardDelegate, retainDelegate: retainDelegate)

RxCocoa/Common/Observable+Bind.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public extension ObservableType {
7575
*/
7676
func bind<Object: AnyObject>(
7777
with object: Object,
78-
onNext: @escaping (Object, Element) -> Void,
78+
onNext: @escaping (Object, Element) -> Void
7979
) -> Disposable {
8080
subscribe(
8181
onNext: { [weak object] in
@@ -84,7 +84,7 @@ public extension ObservableType {
8484
},
8585
onError: { error in
8686
rxFatalErrorInDebug("Binding error: \(error)")
87-
},
87+
}
8888
)
8989
}
9090

@@ -101,7 +101,7 @@ public extension ObservableType {
101101
onNext: onNext,
102102
onError: { error in
103103
rxFatalErrorInDebug("Binding error: \(error)")
104-
},
104+
}
105105
)
106106
}
107107
}

RxCocoa/Foundation/NSObject+Rx.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public extension Reactive where Base: NSObject {
6565
_: Element.Type,
6666
_ keyPath: String,
6767
options: KeyValueObservingOptions = [.new, .initial],
68-
retainSelf: Bool = true,
68+
retainSelf: Bool = true
6969
) -> Observable<Element?> {
7070
KVOObservable(object: base, keyPath: keyPath, options: options, retainTarget: retainSelf).asObservable()
7171
}
@@ -82,7 +82,7 @@ public extension Reactive where Base: NSObject {
8282
*/
8383
func observe<Element>(
8484
_ keyPath: KeyPath<Base, Element>,
85-
options: NSKeyValueObservingOptions = [.new, .initial],
85+
options: NSKeyValueObservingOptions = [.new, .initial]
8686
) -> Observable<Element> {
8787
Observable<Element>.create { [weak base] observer in
8888
let observation = base?.observe(keyPath, options: options) { obj, _ in
@@ -237,7 +237,7 @@ public extension Reactive where Base: AnyObject {
237237
base,
238238
selectorReference,
239239
subject,
240-
.OBJC_ASSOCIATION_RETAIN_NONATOMIC,
240+
.OBJC_ASSOCIATION_RETAIN_NONATOMIC
241241
)
242242
}
243243

@@ -475,9 +475,13 @@ private extension ObservableType where Element == AnyObject? {
475475
private func observeWeaklyKeyPathFor(
476476
_ target: NSObject,
477477
keyPathSections: [String],
478-
options: KeyValueObservingOptions,
478+
options: KeyValueObservingOptions
479479
) -> Observable<AnyObject?> {
480+
#if swift(>=6.2)
480481
weak let weakTarget: AnyObject? = target
482+
#else
483+
weak var weakTarget: AnyObject? = target
484+
#endif
481485

482486
let propertyName = keyPathSections[0]
483487
let remainingPaths = Array(keyPathSections[1 ..< keyPathSections.count])

0 commit comments

Comments
 (0)