Skip to content

Commit 1e33227

Browse files
Alex293davdroman
andauthored
[Misc] Fix more concurrency warnings + CI for beta platforms (#422)
Co-authored-by: David Roman <[email protected]>
1 parent 9068014 commit 1e33227

File tree

83 files changed

+367
-234
lines changed

Some content is hidden

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

83 files changed

+367
-234
lines changed

.github/workflows/ci.yml

+12
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ jobs:
6868
runtime: iOS 17.5
6969
os: macos-14
7070
xcode: 15.4
71+
- platform: [iOS, 18]
72+
runtime: iOS 18.0
73+
os: macos-14
74+
xcode: 16.0
7175

7276
- platform: [tvOS, 13]
7377
runtime: tvOS 13.4
@@ -92,6 +96,10 @@ jobs:
9296
runtime: tvOS 17.5
9397
os: macos-14
9498
xcode: 15.4
99+
- platform: [tvOS, 18]
100+
runtime: tvOS 18.0
101+
os: macos-14
102+
xcode: 16.0
95103

96104
- platform: [watchOS, 8]
97105
runtime: watchOS 8.5
@@ -106,6 +114,10 @@ jobs:
106114
runtime: watchOS 10.5
107115
os: macos-14
108116
xcode: 15.4
117+
- platform: [watchOS, 11]
118+
runtime: watchOS 11.0
119+
os: macos-14
120+
xcode: 16.0
109121

110122
- platform: [macOS, 12]
111123
runtime: macOS 12

Examples/Showcase/Showcase/AppView.swift

+29-29
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct AppView: View {
77
#if os(iOS) || os(tvOS) || os(visionOS)
88
.introspect(
99
.window,
10-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
10+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
1111
) { window in
1212
window.backgroundColor = .brown
1313
}
@@ -46,7 +46,7 @@ struct ContentView: View {
4646
.tag(5)
4747
}
4848
#if os(iOS) || os(tvOS)
49-
.introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17)) { tabBarController in
49+
.introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18)) { tabBarController in
5050
tabBarController.tabBar.layer.backgroundColor = UIColor.green.cgColor
5151
}
5252
#elseif os(macOS)
@@ -83,11 +83,11 @@ struct ListShowcase: View {
8383
Text("Item 2")
8484
}
8585
#if os(iOS) || os(tvOS) || os(visionOS)
86-
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17)) { tableView in
86+
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18)) { tableView in
8787
tableView.backgroundView = UIView()
8888
tableView.backgroundColor = .cyan
8989
}
90-
.introspect(.list, on: .iOS(.v16, .v17), .visionOS(.v1)) { collectionView in
90+
.introspect(.list, on: .iOS(.v16, .v17, .v18), .visionOS(.v1)) { collectionView in
9191
collectionView.backgroundView = UIView()
9292
collectionView.subviews.dropFirst(1).first?.backgroundColor = .cyan
9393
}
@@ -108,11 +108,11 @@ struct ListShowcase: View {
108108
Text("Item 1")
109109
Text("Item 2")
110110
#if os(iOS) || os(tvOS) || os(visionOS)
111-
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17), scope: .ancestor) { tableView in
111+
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), scope: .ancestor) { tableView in
112112
tableView.backgroundView = UIView()
113113
tableView.backgroundColor = .cyan
114114
}
115-
.introspect(.list, on: .iOS(.v16, .v17), .visionOS(.v1), scope: .ancestor) { collectionView in
115+
.introspect(.list, on: .iOS(.v16, .v17, .v18), .visionOS(.v1), scope: .ancestor) { collectionView in
116116
collectionView.backgroundView = UIView()
117117
collectionView.subviews.dropFirst(1).first?.backgroundColor = .cyan
118118
}
@@ -150,7 +150,7 @@ struct ScrollViewShowcase: View {
150150
#if os(iOS) || os(tvOS) || os(visionOS)
151151
.introspect(
152152
.scrollView,
153-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
153+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
154154
) { scrollView in
155155
scrollView.layer.backgroundColor = UIColor.cyan.cgColor
156156
}
@@ -171,7 +171,7 @@ struct ScrollViewShowcase: View {
171171
#if os(iOS) || os(tvOS) || os(visionOS)
172172
.introspect(
173173
.scrollView,
174-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1),
174+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1),
175175
scope: .ancestor
176176
) { scrollView in
177177
scrollView.layer.backgroundColor = UIColor.cyan.cgColor
@@ -207,26 +207,26 @@ struct NavigationShowcase: View {
207207
#if os(iOS) || os(tvOS) || os(visionOS)
208208
.introspect(
209209
.navigationView(style: .stack),
210-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
210+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
211211
) { navigationController in
212212
navigationController.navigationBar.backgroundColor = .cyan
213213
}
214214
.introspect(
215215
.navigationView(style: .columns),
216-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
216+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
217217
) { splitViewController in
218218
#if os(visionOS)
219219
splitViewController.preferredDisplayMode = .oneBesideSecondary
220220
#else
221221
splitViewController.preferredDisplayMode = .oneOverSecondary
222222
#endif
223223
}
224-
.introspect(.navigationView(style: .columns), on: .tvOS(.v13, .v14, .v15, .v16, .v17)) { navigationController in
224+
.introspect(.navigationView(style: .columns), on: .tvOS(.v13, .v14, .v15, .v16, .v17, .v18)) { navigationController in
225225
navigationController.navigationBar.backgroundColor = .cyan
226226
}
227227
.introspect(
228228
.searchField,
229-
on: .iOS(.v15, .v16, .v17), .tvOS(.v15, .v16, .v17), .visionOS(.v1)
229+
on: .iOS(.v15, .v16, .v17, .v18), .tvOS(.v15, .v16, .v17, .v18), .visionOS(.v1)
230230
) { searchBar in
231231
searchBar.backgroundColor = .red
232232
#if os(iOS)
@@ -251,7 +251,7 @@ struct PresentationShowcase: View {
251251
#if os(iOS) || os(tvOS)
252252
.introspect(
253253
.sheet,
254-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17)
254+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18)
255255
) { presentationController in
256256
presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75)
257257
}
@@ -269,7 +269,7 @@ struct PresentationShowcase: View {
269269
#if os(iOS) || os(tvOS) || os(visionOS)
270270
.introspect(
271271
.fullScreenCover,
272-
on: .iOS(.v14, .v15, .v16, .v17), .tvOS(.v14, .v15, .v16, .v17), .visionOS(.v1)
272+
on: .iOS(.v14, .v15, .v16, .v17, .v18), .tvOS(.v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
273273
) { presentationController in
274274
presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75)
275275
}
@@ -284,7 +284,7 @@ struct PresentationShowcase: View {
284284
.padding()
285285
.introspect(
286286
.popover,
287-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
287+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
288288
) { presentationController in
289289
presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75)
290290
}
@@ -305,7 +305,7 @@ struct GenericViewShowcase: View {
305305
#if os(iOS) || os(tvOS) || os(visionOS)
306306
.introspect(
307307
.view,
308-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
308+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
309309
) { view in
310310
view.backgroundColor = .cyan
311311
}
@@ -320,7 +320,7 @@ struct GenericViewShowcase: View {
320320
#if os(iOS) || os(tvOS) || os(visionOS)
321321
.introspect(
322322
.view,
323-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
323+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
324324
) { view in
325325
view.backgroundColor = .lightGray
326326
}
@@ -334,7 +334,7 @@ struct GenericViewShowcase: View {
334334
#if os(iOS) || os(tvOS) || os(visionOS)
335335
.introspect(
336336
.view,
337-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
337+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
338338
) { view in
339339
view.backgroundColor = .blue
340340
}
@@ -348,7 +348,7 @@ struct GenericViewShowcase: View {
348348
#if os(iOS) || os(tvOS) || os(visionOS)
349349
.introspect(
350350
.view,
351-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
351+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
352352
) { view in
353353
view.backgroundColor = .red
354354
}
@@ -375,7 +375,7 @@ struct SimpleElementsShowcase: View {
375375
#if os(iOS) || os(tvOS) || os(visionOS)
376376
.introspect(
377377
.textField,
378-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
378+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
379379
) { textField in
380380
textField.backgroundColor = .red
381381
}
@@ -390,7 +390,7 @@ struct SimpleElementsShowcase: View {
390390
#if os(iOS) || os(tvOS) || os(visionOS)
391391
.introspect(
392392
.textField,
393-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
393+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
394394
) { textField in
395395
textField.backgroundColor = .green
396396
}
@@ -408,7 +408,7 @@ struct SimpleElementsShowcase: View {
408408
#if os(iOS)
409409
.introspect(
410410
.toggle,
411-
on: .iOS(.v13, .v14, .v15, .v16, .v17)
411+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)
412412
) { toggle in
413413
toggle.backgroundColor = .red
414414
}
@@ -422,7 +422,7 @@ struct SimpleElementsShowcase: View {
422422
#if os(iOS)
423423
.introspect(
424424
.toggle,
425-
on: .iOS(.v13, .v14, .v15, .v16, .v17)
425+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)
426426
) { toggle in
427427
toggle.backgroundColor = .green
428428
}
@@ -436,7 +436,7 @@ struct SimpleElementsShowcase: View {
436436
HStack {
437437
Slider(value: $sliderValue, in: 0...100)
438438
#if os(iOS)
439-
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { slider in
439+
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { slider in
440440
slider.backgroundColor = .red
441441
}
442442
#elseif os(macOS)
@@ -447,7 +447,7 @@ struct SimpleElementsShowcase: View {
447447

448448
Slider(value: $sliderValue, in: 0...100)
449449
#if os(iOS)
450-
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { slider in
450+
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { slider in
451451
slider.backgroundColor = .green
452452
}
453453
#elseif os(macOS)
@@ -462,7 +462,7 @@ struct SimpleElementsShowcase: View {
462462
Text("Stepper Red")
463463
}
464464
#if os(iOS)
465-
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { stepper in
465+
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { stepper in
466466
stepper.backgroundColor = .red
467467
}
468468
#elseif os(macOS)
@@ -475,7 +475,7 @@ struct SimpleElementsShowcase: View {
475475
Text("Stepper Green")
476476
}
477477
#if os(iOS)
478-
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { stepper in
478+
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { stepper in
479479
stepper.backgroundColor = .green
480480
}
481481
#elseif os(macOS)
@@ -491,7 +491,7 @@ struct SimpleElementsShowcase: View {
491491
Text("DatePicker Red")
492492
}
493493
#if os(iOS) || os(visionOS)
494-
.introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)) { datePicker in
494+
.introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)) { datePicker in
495495
datePicker.backgroundColor = .red
496496
}
497497
#elseif os(macOS)
@@ -512,7 +512,7 @@ struct SimpleElementsShowcase: View {
512512
#if os(iOS) || os(tvOS) || os(visionOS)
513513
.introspect(
514514
.picker(style: .segmented),
515-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
515+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
516516
) { datePicker in
517517
datePicker.backgroundColor = .red
518518
}

Package.swift

-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,5 @@ let package = Package(
1919
name: "SwiftUIIntrospect",
2020
path: "Sources"
2121
),
22-
],
23-
swiftLanguageVersions: [
24-
.v5,
25-
.version("6.0"),
2622
]
2723
)

[email protected]

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// swift-tools-version:6.0
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "swiftui-introspect",
7+
platforms: [
8+
.iOS(.v13),
9+
.tvOS(.v13),
10+
.macOS(.v10_15),
11+
],
12+
products: [
13+
.library(name: "SwiftUIIntrospect", targets: ["SwiftUIIntrospect"]),
14+
.library(name: "SwiftUIIntrospect-Static", type: .static, targets: ["SwiftUIIntrospect"]),
15+
.library(name: "SwiftUIIntrospect-Dynamic", type: .dynamic, targets: ["SwiftUIIntrospect"]),
16+
],
17+
targets: [
18+
.target(
19+
name: "SwiftUIIntrospect",
20+
path: "Sources"
21+
),
22+
],
23+
swiftLanguageVersions: [.v6]
24+
)

Sources/Introspect.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ extension View {
3434
///
3535
/// var body: some View {
3636
/// TextField("Placeholder", text: $text)
37-
/// .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17)) {
37+
/// .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) {
3838
/// print(type(of: $0)) // UITextField
3939
/// }
4040
/// }
4141
/// }
4242
/// ```
43+
@MainActor
4344
public func introspect<SwiftUIViewType: IntrospectableViewType, PlatformSpecificEntity: PlatformEntity>(
4445
_ viewType: SwiftUIViewType,
4546
on platforms: (PlatformViewVersionPredicate<SwiftUIViewType, PlatformSpecificEntity>)...,
@@ -56,6 +57,7 @@ struct IntrospectModifier<SwiftUIViewType: IntrospectableViewType, PlatformSpeci
5657
let selector: IntrospectionSelector<PlatformSpecificEntity>?
5758
let customize: (PlatformSpecificEntity) -> Void
5859

60+
@MainActor
5961
init(
6062
_ viewType: SwiftUIViewType,
6163
platforms: [PlatformViewVersionPredicate<SwiftUIViewType, PlatformSpecificEntity>],

Sources/IntrospectableViewType.swift

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#if !os(watchOS)
2+
@MainActor
23
public protocol IntrospectableViewType {
34
/// The scope of introspection for this particular view type, i.e. where introspect
45
/// should look to find the desired target view relative to the applied

0 commit comments

Comments
 (0)