Skip to content

Commit 668a657

Browse files
Add new platform versions for WWDC24 (#420)
Co-authored-by: KKirsten <kirsten@for-sale-mobile.de>
1 parent c561e0d commit 668a657

Some content is hidden

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

52 files changed

+355
-156
lines changed

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ For instance, when introspecting a `ScrollView`...
2020
ScrollView {
2121
Text("Item 1")
2222
}
23-
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { scrollView in
23+
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { scrollView in
2424
// do something with UIScrollView
2525
}
2626
```
@@ -38,7 +38,7 @@ By default, the `.introspect` modifier acts directly on its _receiver_. This mea
3838
```swift
3939
ScrollView {
4040
Text("Item 1")
41-
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17), scope: .ancestor) { scrollView in
41+
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), scope: .ancestor) { scrollView in
4242
// do something with UIScrollView
4343
}
4444
}
@@ -157,7 +157,7 @@ List {
157157
tableView.backgroundView = UIView()
158158
tableView.backgroundColor = .cyan
159159
}
160-
.introspect(.list, on: .iOS(.v16, .v17)) { collectionView in
160+
.introspect(.list, on: .iOS(.v16, .v17, .v18)) { collectionView in
161161
collectionView.backgroundView = UIView()
162162
collectionView.subviews.dropFirst(1).first?.backgroundColor = .cyan
163163
}
@@ -169,7 +169,7 @@ List {
169169
ScrollView {
170170
Text("Item")
171171
}
172-
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { scrollView in
172+
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { scrollView in
173173
scrollView.backgroundColor = .red
174174
}
175175
```
@@ -181,7 +181,7 @@ NavigationView {
181181
Text("Item")
182182
}
183183
.navigationViewStyle(.stack)
184-
.introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16, .v17)) { navigationController in
184+
.introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { navigationController in
185185
navigationController.navigationBar.backgroundColor = .cyan
186186
}
187187
```
@@ -190,7 +190,7 @@ NavigationView {
190190

191191
```swift
192192
TextField("Text Field", text: <#Binding<String>#>)
193-
.introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { textField in
193+
.introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { textField in
194194
textField.backgroundColor = .red
195195
}
196196
```
@@ -269,7 +269,7 @@ struct ContentView: View {
269269
}
270270
```
271271

272-
Bear in mind this should be used cautiously, and with full knowledge that any future OS version might break the expected introspection types unless explicitly available. For instance, if in the example above hypothetically iOS 18 stops using UIScrollView under the hood, the customization closure will never be called on said platform.
272+
Bear in mind this should be used cautiously, and with full knowledge that any future OS version might break the expected introspection types unless explicitly available. For instance, if in the example above hypothetically iOS 19 stops using UIScrollView under the hood, the customization closure will never be called on said platform.
273273

274274
### Keep instances outside the customize closure
275275

@@ -286,7 +286,7 @@ struct ContentView: View {
286286
ScrollView {
287287
// ...
288288
}
289-
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { scrollView in
289+
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { scrollView in
290290
self.scrollView = scrollView
291291
}
292292
}

Sources/PlatformVersion.swift

+58-2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ extension iOSVersion {
108108
return nil
109109
#endif
110110
}
111+
112+
public static let v18 = iOSVersion {
113+
#if os(iOS)
114+
if #available(iOS 19, *) {
115+
return .past
116+
}
117+
if #available(iOS 18, *) {
118+
return .current
119+
}
120+
return .future
121+
#else
122+
return nil
123+
#endif
124+
}
111125
}
112126

113127
public struct tvOSVersion: PlatformVersion {
@@ -176,16 +190,30 @@ extension tvOSVersion {
176190
return nil
177191
#endif
178192
}
179-
193+
180194
public static let v17 = tvOSVersion {
181-
#if os(tvOS)
195+
#if os(tvOS)
182196
if #available(tvOS 18, *) {
183197
return .past
184198
}
185199
if #available(tvOS 17, *) {
186200
return .current
187201
}
188202
return .future
203+
#else
204+
return nil
205+
#endif
206+
}
207+
208+
public static let v18 = tvOSVersion {
209+
#if os(tvOS)
210+
if #available(tvOS 19, *) {
211+
return .past
212+
}
213+
if #available(tvOS 18, *) {
214+
return .current
215+
}
216+
return .future
189217
#else
190218
return nil
191219
#endif
@@ -286,6 +314,20 @@ extension macOSVersion {
286314
return nil
287315
#endif
288316
}
317+
318+
public static let v15 = macOSVersion {
319+
#if os(macOS)
320+
if #available(macOS 16, *) {
321+
return .past
322+
}
323+
if #available(macOS 15, *) {
324+
return .current
325+
}
326+
return .future
327+
#else
328+
return nil
329+
#endif
330+
}
289331
}
290332

291333
public struct visionOSVersion: PlatformVersion {
@@ -312,5 +354,19 @@ extension visionOSVersion {
312354
return nil
313355
#endif
314356
}
357+
358+
public static let v2 = visionOSVersion {
359+
#if os(visionOS)
360+
if #available(visionOS 3, *) {
361+
return .past
362+
}
363+
if #available(visionOS 2, *) {
364+
return .current
365+
}
366+
return .future
367+
#else
368+
return nil
369+
#endif
370+
}
315371
}
316372
#endif

Sources/ViewTypes/Button.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import SwiftUI
1717
/// struct ContentView: View {
1818
/// var body: some View {
1919
/// Button("Action", action: {})
20-
/// .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
20+
/// .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15)) {
2121
/// print(type(of: $0)) // NSButton
2222
/// }
2323
/// }
@@ -41,6 +41,7 @@ extension macOSViewVersion<ButtonType, NSButton> {
4141
public static let v12 = Self(for: .v12)
4242
public static let v13 = Self(for: .v13)
4343
public static let v14 = Self(for: .v14)
44+
public static let v15 = Self(for: .v15)
4445
}
4546
#endif
4647
#endif

Sources/ViewTypes/ColorPicker.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import SwiftUI
1111
///
1212
/// var body: some View {
1313
/// ColorPicker("Pick a color", selection: $color)
14-
/// .introspect(.colorPicker, on: .iOS(.v14, .v15, .v16, .v17)) {
14+
/// .introspect(.colorPicker, on: .iOS(.v14, .v15, .v16, .v17, .v18)) {
1515
/// print(type(of: $0)) // UIColorPicker
1616
/// }
1717
/// }
@@ -30,7 +30,7 @@ import SwiftUI
3030
///
3131
/// var body: some View {
3232
/// ColorPicker("Pick a color", selection: $color)
33-
/// .introspect(.colorPicker, on: .macOS(.v11, .v12, .v13, .v14)) {
33+
/// .introspect(.colorPicker, on: .macOS(.v11, .v12, .v13, .v14, .v15)) {
3434
/// print(type(of: $0)) // NSColorPicker
3535
/// }
3636
/// }
@@ -67,6 +67,7 @@ extension iOSViewVersion<ColorPickerType, UIColorWell> {
6767
public static let v15 = Self(for: .v15)
6868
public static let v16 = Self(for: .v16)
6969
public static let v17 = Self(for: .v17)
70+
public static let v18 = Self(for: .v18)
7071
}
7172

7273
@available(iOS 14, *)
@@ -82,6 +83,7 @@ extension macOSViewVersion<ColorPickerType, NSColorWell> {
8283
public static let v12 = Self(for: .v12)
8384
public static let v13 = Self(for: .v13)
8485
public static let v14 = Self(for: .v14)
86+
public static let v15 = Self(for: .v15)
8587
}
8688
#endif
8789
#endif

Sources/ViewTypes/DatePicker.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import SwiftUI
1111
///
1212
/// var body: some View {
1313
/// DatePicker("Pick a date", selection: $date)
14-
/// .introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17)) {
14+
/// .introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) {
1515
/// print(type(of: $0)) // UIDatePicker
1616
/// }
1717
/// }
@@ -28,7 +28,7 @@ import SwiftUI
2828
///
2929
/// var body: some View {
3030
/// DatePicker("Pick a date", selection: $date)
31-
/// .introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
31+
/// .introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15)) {
3232
/// print(type(of: $0)) // NSDatePicker
3333
/// }
3434
/// }
@@ -43,7 +43,7 @@ import SwiftUI
4343
///
4444
/// var body: some View {
4545
/// DatePicker("Pick a date", selection: $date)
46-
/// .introspect(.datePicker, on: .visionOS(.v1)) {
46+
/// .introspect(.datePicker, on: .visionOS(.v1, .v2)) {
4747
/// print(type(of: $0)) // UIDatePicker
4848
/// }
4949
/// }
@@ -63,10 +63,12 @@ extension iOSViewVersion<DatePickerType, UIDatePicker> {
6363
public static let v15 = Self(for: .v15)
6464
public static let v16 = Self(for: .v16)
6565
public static let v17 = Self(for: .v17)
66+
public static let v18 = Self(for: .v18)
6667
}
6768

6869
extension visionOSViewVersion<DatePickerType, UIDatePicker> {
6970
public static let v1 = Self(for: .v1)
71+
public static let v2 = Self(for: .v2)
7072
}
7173
#elseif canImport(AppKit)
7274
extension macOSViewVersion<DatePickerType, NSDatePicker> {
@@ -75,6 +77,7 @@ extension macOSViewVersion<DatePickerType, NSDatePicker> {
7577
public static let v12 = Self(for: .v12)
7678
public static let v13 = Self(for: .v13)
7779
public static let v14 = Self(for: .v14)
80+
public static let v15 = Self(for: .v15)
7881
}
7982
#endif
8083
#endif

Sources/ViewTypes/DatePickerWithCompactStyle.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import SwiftUI
1212
/// var body: some View {
1313
/// DatePicker("Pick a date", selection: $date)
1414
/// .datePickerStyle(.compact)
15-
/// .introspect(.datePicker(style: .compact), on: .iOS(.v14, .v15, .v16, .v17)) {
15+
/// .introspect(.datePicker(style: .compact), on: .iOS(.v14, .v15, .v16, .v17, .v18)) {
1616
/// print(type(of: $0)) // UIDatePicker
1717
/// }
1818
/// }
@@ -32,7 +32,7 @@ import SwiftUI
3232
/// var body: some View {
3333
/// DatePicker("Pick a date", selection: $date)
3434
/// .datePickerStyle(.compact)
35-
/// .introspect(.datePicker(style: .compact), on: .macOS(.v10_15_4, .v11, .v12, .v13, .v14)) {
35+
/// .introspect(.datePicker(style: .compact), on: .macOS(.v10_15_4, .v11, .v12, .v13, .v14, .v15)) {
3636
/// print(type(of: $0)) // NSDatePicker
3737
/// }
3838
/// }
@@ -48,7 +48,7 @@ import SwiftUI
4848
/// var body: some View {
4949
/// DatePicker("Pick a date", selection: $date)
5050
/// .datePickerStyle(.compact)
51-
/// .introspect(.datePicker(style: .compact), on: .visionOS(.v1)) {
51+
/// .introspect(.datePicker(style: .compact), on: .visionOS(.v1, .v2)) {
5252
/// print(type(of: $0)) // UIDatePicker
5353
/// }
5454
/// }
@@ -73,10 +73,12 @@ extension iOSViewVersion<DatePickerWithCompactStyleType, UIDatePicker> {
7373
public static let v15 = Self(for: .v15)
7474
public static let v16 = Self(for: .v16)
7575
public static let v17 = Self(for: .v17)
76+
public static let v18 = Self(for: .v18)
7677
}
7778

7879
extension visionOSViewVersion<DatePickerWithCompactStyleType, UIDatePicker> {
7980
public static let v1 = Self(for: .v1)
81+
public static let v2 = Self(for: .v2)
8082
}
8183
#elseif canImport(AppKit) && !targetEnvironment(macCatalyst)
8284
extension macOSViewVersion<DatePickerWithCompactStyleType, NSDatePicker> {
@@ -87,6 +89,7 @@ extension macOSViewVersion<DatePickerWithCompactStyleType, NSDatePicker> {
8789
public static let v12 = Self(for: .v12)
8890
public static let v13 = Self(for: .v13)
8991
public static let v14 = Self(for: .v14)
92+
public static let v15 = Self(for: .v15)
9093
}
9194
#endif
9295
#endif

Sources/ViewTypes/DatePickerWithFieldStyle.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import SwiftUI
2020
/// var body: some View {
2121
/// DatePicker("Pick a date", selection: $date)
2222
/// .datePickerStyle(.field)
23-
/// .introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
23+
/// .introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15)) {
2424
/// print(type(of: $0)) // NSDatePicker
2525
/// }
2626
/// }
@@ -48,6 +48,7 @@ extension macOSViewVersion<DatePickerWithFieldStyleType, NSDatePicker> {
4848
public static let v12 = Self(for: .v12)
4949
public static let v13 = Self(for: .v13)
5050
public static let v14 = Self(for: .v14)
51+
public static let v15 = Self(for: .v15)
5152
}
5253
#endif
5354
#endif

Sources/ViewTypes/DatePickerWithGraphicalStyle.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import SwiftUI
1212
/// var body: some View {
1313
/// DatePicker("Pick a date", selection: $date)
1414
/// .datePickerStyle(.graphical)
15-
/// .introspect(.datePicker(style: .graphical), on: .iOS(.v14, .v15, .v16, .v17)) {
15+
/// .introspect(.datePicker(style: .graphical), on: .iOS(.v14, .v15, .v16, .v17, .v18)) {
1616
/// print(type(of: $0)) // UIDatePicker
1717
/// }
1818
/// }
@@ -32,7 +32,7 @@ import SwiftUI
3232
/// var body: some View {
3333
/// DatePicker("Pick a date", selection: $date)
3434
/// .datePickerStyle(.graphical)
35-
/// .introspect(.datePicker(style: .graphical), on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
35+
/// .introspect(.datePicker(style: .graphical), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15)) {
3636
/// print(type(of: $0)) // NSDatePicker
3737
/// }
3838
/// }
@@ -48,7 +48,7 @@ import SwiftUI
4848
/// var body: some View {
4949
/// DatePicker("Pick a date", selection: $date)
5050
/// .datePickerStyle(.graphical)
51-
/// .introspect(.datePicker(style: .graphical), on: .visionOS(.v1)) {
51+
/// .introspect(.datePicker(style: .graphical), on: .visionOS(.v1, .v2)) {
5252
/// print(type(of: $0)) // UIDatePicker
5353
/// }
5454
/// }
@@ -73,10 +73,12 @@ extension iOSViewVersion<DatePickerWithGraphicalStyleType, UIDatePicker> {
7373
public static let v15 = Self(for: .v15)
7474
public static let v16 = Self(for: .v16)
7575
public static let v17 = Self(for: .v17)
76+
public static let v18 = Self(for: .v18)
7677
}
7778

7879
extension visionOSViewVersion<DatePickerWithGraphicalStyleType, UIDatePicker> {
7980
public static let v1 = Self(for: .v1)
81+
public static let v2 = Self(for: .v2)
8082
}
8183
#elseif canImport(AppKit) && !targetEnvironment(macCatalyst)
8284
extension macOSViewVersion<DatePickerWithGraphicalStyleType, NSDatePicker> {
@@ -85,6 +87,7 @@ extension macOSViewVersion<DatePickerWithGraphicalStyleType, NSDatePicker> {
8587
public static let v12 = Self(for: .v12)
8688
public static let v13 = Self(for: .v13)
8789
public static let v14 = Self(for: .v14)
90+
public static let v15 = Self(for: .v15)
8891
}
8992
#endif
9093
#endif

Sources/ViewTypes/DatePickerWithStepperFieldStyle.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import SwiftUI
2020
/// var body: some View {
2121
/// DatePicker("Pick a date", selection: $date)
2222
/// .datePickerStyle(.stepperField)
23-
/// .introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
23+
/// .introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15)) {
2424
/// print(type(of: $0)) // NSDatePicker
2525
/// }
2626
/// }
@@ -48,6 +48,7 @@ extension macOSViewVersion<DatePickerWithStepperFieldStyleType, NSDatePicker> {
4848
public static let v12 = Self(for: .v12)
4949
public static let v13 = Self(for: .v13)
5050
public static let v14 = Self(for: .v14)
51+
public static let v15 = Self(for: .v15)
5152
}
5253
#endif
5354
#endif

0 commit comments

Comments
 (0)