Skip to content

Commit

Permalink
[Misc] Fix more concurrency warnings + CI for beta platforms (#422)
Browse files Browse the repository at this point in the history
Co-authored-by: David Roman <[email protected]>
  • Loading branch information
Alex293 and davdroman committed Jul 17, 2024
1 parent 9068014 commit 1e33227
Show file tree
Hide file tree
Showing 83 changed files with 367 additions and 234 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ jobs:
runtime: iOS 17.5
os: macos-14
xcode: 15.4
- platform: [iOS, 18]
runtime: iOS 18.0
os: macos-14
xcode: 16.0

- platform: [tvOS, 13]
runtime: tvOS 13.4
Expand All @@ -92,6 +96,10 @@ jobs:
runtime: tvOS 17.5
os: macos-14
xcode: 15.4
- platform: [tvOS, 18]
runtime: tvOS 18.0
os: macos-14
xcode: 16.0

- platform: [watchOS, 8]
runtime: watchOS 8.5
Expand All @@ -106,6 +114,10 @@ jobs:
runtime: watchOS 10.5
os: macos-14
xcode: 15.4
- platform: [watchOS, 11]
runtime: watchOS 11.0
os: macos-14
xcode: 16.0

- platform: [macOS, 12]
runtime: macOS 12
Expand Down
58 changes: 29 additions & 29 deletions Examples/Showcase/Showcase/AppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct AppView: View {
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(
.window,
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { window in
window.backgroundColor = .brown
}
Expand Down Expand Up @@ -46,7 +46,7 @@ struct ContentView: View {
.tag(5)
}
#if os(iOS) || os(tvOS)
.introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17)) { tabBarController in
.introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18)) { tabBarController in
tabBarController.tabBar.layer.backgroundColor = UIColor.green.cgColor
}
#elseif os(macOS)
Expand Down Expand Up @@ -83,11 +83,11 @@ struct ListShowcase: View {
Text("Item 2")
}
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17)) { tableView in
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18)) { tableView in
tableView.backgroundView = UIView()
tableView.backgroundColor = .cyan
}
.introspect(.list, on: .iOS(.v16, .v17), .visionOS(.v1)) { collectionView in
.introspect(.list, on: .iOS(.v16, .v17, .v18), .visionOS(.v1)) { collectionView in
collectionView.backgroundView = UIView()
collectionView.subviews.dropFirst(1).first?.backgroundColor = .cyan
}
Expand All @@ -108,11 +108,11 @@ struct ListShowcase: View {
Text("Item 1")
Text("Item 2")
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17), scope: .ancestor) { tableView in
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), scope: .ancestor) { tableView in
tableView.backgroundView = UIView()
tableView.backgroundColor = .cyan
}
.introspect(.list, on: .iOS(.v16, .v17), .visionOS(.v1), scope: .ancestor) { collectionView in
.introspect(.list, on: .iOS(.v16, .v17, .v18), .visionOS(.v1), scope: .ancestor) { collectionView in
collectionView.backgroundView = UIView()
collectionView.subviews.dropFirst(1).first?.backgroundColor = .cyan
}
Expand Down Expand Up @@ -150,7 +150,7 @@ struct ScrollViewShowcase: View {
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(
.scrollView,
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { scrollView in
scrollView.layer.backgroundColor = UIColor.cyan.cgColor
}
Expand All @@ -171,7 +171,7 @@ struct ScrollViewShowcase: View {
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(
.scrollView,
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1),
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1),
scope: .ancestor
) { scrollView in
scrollView.layer.backgroundColor = UIColor.cyan.cgColor
Expand Down Expand Up @@ -207,26 +207,26 @@ struct NavigationShowcase: View {
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(
.navigationView(style: .stack),
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { navigationController in
navigationController.navigationBar.backgroundColor = .cyan
}
.introspect(
.navigationView(style: .columns),
on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { splitViewController in
#if os(visionOS)
splitViewController.preferredDisplayMode = .oneBesideSecondary
#else
splitViewController.preferredDisplayMode = .oneOverSecondary
#endif
}
.introspect(.navigationView(style: .columns), on: .tvOS(.v13, .v14, .v15, .v16, .v17)) { navigationController in
.introspect(.navigationView(style: .columns), on: .tvOS(.v13, .v14, .v15, .v16, .v17, .v18)) { navigationController in
navigationController.navigationBar.backgroundColor = .cyan
}
.introspect(
.searchField,
on: .iOS(.v15, .v16, .v17), .tvOS(.v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v15, .v16, .v17, .v18), .tvOS(.v15, .v16, .v17, .v18), .visionOS(.v1)
) { searchBar in
searchBar.backgroundColor = .red
#if os(iOS)
Expand All @@ -251,7 +251,7 @@ struct PresentationShowcase: View {
#if os(iOS) || os(tvOS)
.introspect(
.sheet,
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18)
) { presentationController in
presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75)
}
Expand All @@ -269,7 +269,7 @@ struct PresentationShowcase: View {
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(
.fullScreenCover,
on: .iOS(.v14, .v15, .v16, .v17), .tvOS(.v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v14, .v15, .v16, .v17, .v18), .tvOS(.v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { presentationController in
presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75)
}
Expand All @@ -284,7 +284,7 @@ struct PresentationShowcase: View {
.padding()
.introspect(
.popover,
on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { presentationController in
presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75)
}
Expand All @@ -305,7 +305,7 @@ struct GenericViewShowcase: View {
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(
.view,
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { view in
view.backgroundColor = .cyan
}
Expand All @@ -320,7 +320,7 @@ struct GenericViewShowcase: View {
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(
.view,
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { view in
view.backgroundColor = .lightGray
}
Expand All @@ -334,7 +334,7 @@ struct GenericViewShowcase: View {
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(
.view,
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { view in
view.backgroundColor = .blue
}
Expand All @@ -348,7 +348,7 @@ struct GenericViewShowcase: View {
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(
.view,
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { view in
view.backgroundColor = .red
}
Expand All @@ -375,7 +375,7 @@ struct SimpleElementsShowcase: View {
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(
.textField,
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { textField in
textField.backgroundColor = .red
}
Expand All @@ -390,7 +390,7 @@ struct SimpleElementsShowcase: View {
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(
.textField,
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { textField in
textField.backgroundColor = .green
}
Expand All @@ -408,7 +408,7 @@ struct SimpleElementsShowcase: View {
#if os(iOS)
.introspect(
.toggle,
on: .iOS(.v13, .v14, .v15, .v16, .v17)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)
) { toggle in
toggle.backgroundColor = .red
}
Expand All @@ -422,7 +422,7 @@ struct SimpleElementsShowcase: View {
#if os(iOS)
.introspect(
.toggle,
on: .iOS(.v13, .v14, .v15, .v16, .v17)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)
) { toggle in
toggle.backgroundColor = .green
}
Expand All @@ -436,7 +436,7 @@ struct SimpleElementsShowcase: View {
HStack {
Slider(value: $sliderValue, in: 0...100)
#if os(iOS)
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { slider in
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { slider in
slider.backgroundColor = .red
}
#elseif os(macOS)
Expand All @@ -447,7 +447,7 @@ struct SimpleElementsShowcase: View {

Slider(value: $sliderValue, in: 0...100)
#if os(iOS)
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { slider in
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { slider in
slider.backgroundColor = .green
}
#elseif os(macOS)
Expand All @@ -462,7 +462,7 @@ struct SimpleElementsShowcase: View {
Text("Stepper Red")
}
#if os(iOS)
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { stepper in
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { stepper in
stepper.backgroundColor = .red
}
#elseif os(macOS)
Expand All @@ -475,7 +475,7 @@ struct SimpleElementsShowcase: View {
Text("Stepper Green")
}
#if os(iOS)
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { stepper in
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { stepper in
stepper.backgroundColor = .green
}
#elseif os(macOS)
Expand All @@ -491,7 +491,7 @@ struct SimpleElementsShowcase: View {
Text("DatePicker Red")
}
#if os(iOS) || os(visionOS)
.introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)) { datePicker in
.introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)) { datePicker in
datePicker.backgroundColor = .red
}
#elseif os(macOS)
Expand All @@ -512,7 +512,7 @@ struct SimpleElementsShowcase: View {
#if os(iOS) || os(tvOS) || os(visionOS)
.introspect(
.picker(style: .segmented),
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18), .visionOS(.v1)
) { datePicker in
datePicker.backgroundColor = .red
}
Expand Down
4 changes: 0 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,5 @@ let package = Package(
name: "SwiftUIIntrospect",
path: "Sources"
),
],
swiftLanguageVersions: [
.v5,
.version("6.0"),
]
)
24 changes: 24 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// swift-tools-version:6.0

import PackageDescription

let package = Package(
name: "swiftui-introspect",
platforms: [
.iOS(.v13),
.tvOS(.v13),
.macOS(.v10_15),
],
products: [
.library(name: "SwiftUIIntrospect", targets: ["SwiftUIIntrospect"]),
.library(name: "SwiftUIIntrospect-Static", type: .static, targets: ["SwiftUIIntrospect"]),
.library(name: "SwiftUIIntrospect-Dynamic", type: .dynamic, targets: ["SwiftUIIntrospect"]),
],
targets: [
.target(
name: "SwiftUIIntrospect",
path: "Sources"
),
],
swiftLanguageVersions: [.v6]
)
4 changes: 3 additions & 1 deletion Sources/Introspect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ extension View {
///
/// var body: some View {
/// TextField("Placeholder", text: $text)
/// .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17)) {
/// .introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) {
/// print(type(of: $0)) // UITextField
/// }
/// }
/// }
/// ```
@MainActor
public func introspect<SwiftUIViewType: IntrospectableViewType, PlatformSpecificEntity: PlatformEntity>(
_ viewType: SwiftUIViewType,
on platforms: (PlatformViewVersionPredicate<SwiftUIViewType, PlatformSpecificEntity>)...,
Expand All @@ -56,6 +57,7 @@ struct IntrospectModifier<SwiftUIViewType: IntrospectableViewType, PlatformSpeci
let selector: IntrospectionSelector<PlatformSpecificEntity>?
let customize: (PlatformSpecificEntity) -> Void

@MainActor
init(
_ viewType: SwiftUIViewType,
platforms: [PlatformViewVersionPredicate<SwiftUIViewType, PlatformSpecificEntity>],
Expand Down
1 change: 1 addition & 0 deletions Sources/IntrospectableViewType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#if !os(watchOS)
@MainActor
public protocol IntrospectableViewType {
/// The scope of introspection for this particular view type, i.e. where introspect
/// should look to find the desired target view relative to the applied
Expand Down
Loading

0 comments on commit 1e33227

Please sign in to comment.