Skip to content

Commit 9d74a67

Browse files
authored
Merge branch 'main' into patch-1
2 parents 8a048e6 + d77b63a commit 9d74a67

Some content is hidden

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

59 files changed

+237
-179
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
fetch-depth: 0 # required to be able to find Git tags
2626

2727
- name: Select Xcode version
28-
run: sudo xcodes select 16.2
28+
run: sudo xcodes select 16.4
2929

3030
- name: Lint Podspec
3131
run: |

Package.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.7
1+
// swift-tools-version:6.0
22

33
import PackageDescription
44

@@ -21,3 +21,11 @@ let package = Package(
2121
),
2222
]
2323
)
24+
25+
for target in package.targets {
26+
target.swiftSettings = target.swiftSettings ?? []
27+
target.swiftSettings? += [
28+
.enableUpcomingFeature("ExistentialAny"),
29+
.enableUpcomingFeature("InternalImportsByDefault"),
30+
]
31+
}

[email protected]

Lines changed: 0 additions & 23 deletions
This file was deleted.

Sources/Introspect.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#if !os(watchOS)
2-
import SwiftUI
2+
public import SwiftUI
33

44
/// The scope of introspection i.e. where introspect should look to find
55
/// the desired target view relative to the applied `.introspect(...)`
@@ -26,6 +26,14 @@ extension View {
2626
/// - scope: Optionally overrides the view's default scope of introspection.
2727
/// - customize: A closure that hands over the underlying UIKit/AppKit instance ready for customization.
2828
///
29+
/// Note there is no guarantee of one-time execution for this closure. As `customize` may fire multiple times,
30+
/// make sure to guard against repeated or heavy work in your closure by keeping track of its completeness.
31+
///
32+
/// Additionally, note mutating SwiftUI state within `customize` will trigger runtime warnings unless that mutation
33+
/// is wrapped in a `DispatchQueue.main.async { ... }` call. This is because introspect attempts to hand you
34+
/// the requested view as soon as possible, and this might mean SwiftUI isn't ready for state mutations at that
35+
/// particular moment.
36+
///
2937
/// Here's an example usage:
3038
///
3139
/// ```swift

Sources/IntrospectionView.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,6 @@ struct IntrospectionView<Target: PlatformEntity>: PlatformViewControllerRepresen
121121
customize(target)
122122
controller.handler = nil
123123
}
124-
125-
// - Workaround -
126-
// iOS/tvOS 13 sometimes need a nudge on the next run loop.
127-
if #available(iOS 14, tvOS 14, *) {} else {
128-
DispatchQueue.main.async { [weak controller] in
129-
controller?.handler?()
130-
}
131-
}
132-
133124
return controller
134125
}
135126

@@ -159,7 +150,13 @@ final class IntrospectionPlatformViewController: PlatformViewController {
159150
guard let self else {
160151
return
161152
}
162-
handler?(self)
153+
154+
// NB: .introspect makes no guarantees about the number of times its callback is invoked,
155+
// so the below is fair play to maximize compatibility and predictability
156+
handler?(self) // we call this eagerly as most customization can successfully happen without a thread hop
157+
DispatchQueue.main.async {
158+
handler?(self) // we also thread hop to cover the rest of the cases where the underlying UI component isn't quite ready for customization
159+
}
163160
}
164161
self.isIntrospectionPlatformEntity = true
165162
IntrospectionStore.shared[id, default: .init()].controller = self

Sources/PlatformView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#if !os(watchOS)
2-
import SwiftUI
2+
public import SwiftUI
33

44
#if canImport(UIKit)
55
public typealias PlatformView = UIView

Sources/ViewTypes/Button.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#if !os(watchOS)
2-
import SwiftUI
3-
42
/// An abstract representation of the `Button` type in SwiftUI.
53
///
64
/// ### iOS
@@ -35,6 +33,8 @@ extension IntrospectableViewType where Self == ButtonType {
3533
}
3634

3735
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
36+
public import AppKit
37+
3838
extension macOSViewVersion<ButtonType, NSButton> {
3939
public static let v10_15 = Self(for: .v10_15)
4040
public static let v11 = Self(for: .v11)

Sources/ViewTypes/ColorPicker.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#if !os(watchOS)
2-
import SwiftUI
3-
42
/// An abstract representation of the `ColorPicker` type in SwiftUI.
53
///
64
/// ### iOS
@@ -59,6 +57,8 @@ extension IntrospectableViewType where Self == ColorPickerType {
5957
}
6058

6159
#if canImport(UIKit)
60+
public import UIKit
61+
6262
@available(iOS 14, *)
6363
extension iOSViewVersion<ColorPickerType, UIColorWell> {
6464
@available(*, unavailable, message: "ColorPicker isn't available on iOS 13")
@@ -78,6 +78,8 @@ extension visionOSViewVersion<ColorPickerType, UIColorWell> {
7878
public static let v26 = Self(for: .v26)
7979
}
8080
#elseif canImport(AppKit)
81+
public import AppKit
82+
8183
@available(macOS 11, *)
8284
extension macOSViewVersion<ColorPickerType, NSColorWell> {
8385
@available(*, unavailable, message: "ColorPicker isn't available on macOS 10.15")

Sources/ViewTypes/DatePicker.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#if !os(watchOS)
2-
import SwiftUI
3-
42
/// An abstract representation of the `DatePicker` type in SwiftUI.
53
///
64
/// ### iOS
@@ -57,6 +55,8 @@ extension IntrospectableViewType where Self == DatePickerType {
5755
}
5856

5957
#if canImport(UIKit)
58+
public import UIKit
59+
6060
extension iOSViewVersion<DatePickerType, UIDatePicker> {
6161
public static let v13 = Self(for: .v13)
6262
public static let v14 = Self(for: .v14)
@@ -73,6 +73,8 @@ extension visionOSViewVersion<DatePickerType, UIDatePicker> {
7373
public static let v26 = Self(for: .v26)
7474
}
7575
#elseif canImport(AppKit)
76+
public import AppKit
77+
7678
extension macOSViewVersion<DatePickerType, NSDatePicker> {
7779
public static let v10_15 = Self(for: .v10_15)
7880
public static let v11 = Self(for: .v11)

Sources/ViewTypes/DatePickerWithCompactStyle.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#if !os(watchOS)
2-
import SwiftUI
3-
42
/// An abstract representation of the `DatePicker` type in SwiftUI, with `.compact` style.
53
///
64
/// ### iOS
@@ -66,6 +64,8 @@ extension IntrospectableViewType where Self == DatePickerWithCompactStyleType {
6664
}
6765

6866
#if canImport(UIKit)
67+
public import UIKit
68+
6969
extension iOSViewVersion<DatePickerWithCompactStyleType, UIDatePicker> {
7070
@available(*, unavailable, message: ".datePickerStyle(.compact) isn't available on iOS 13")
7171
public static let v13 = Self.unavailable()
@@ -83,6 +83,8 @@ extension visionOSViewVersion<DatePickerWithCompactStyleType, UIDatePicker> {
8383
public static let v26 = Self(for: .v26)
8484
}
8585
#elseif canImport(AppKit) && !targetEnvironment(macCatalyst)
86+
public import AppKit
87+
8688
extension macOSViewVersion<DatePickerWithCompactStyleType, NSDatePicker> {
8789
@available(*, unavailable, message: ".datePickerStyle(.compact) isn't available on macOS 10.15")
8890
public static let v10_15 = Self.unavailable()

0 commit comments

Comments
 (0)