Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict Concurrency #298

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ let package = Package(
],
targets: [
.target(
name: "ViewInspector", dependencies: []),
name: "ViewInspector",
dependencies: [],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may not need to declare it at the package level - if you open the project through ViewInspector.xcodeproj instead of Package.swift, that should be possible to enable this setting internally in the project

]),
.testTarget(
name: "ViewInspectorTests",
dependencies: ["ViewInspector"],
Expand Down
8 changes: 5 additions & 3 deletions Sources/ViewInspector/BaseTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public protocol MultipleViewContent {
internal typealias SupplementaryView = UnwrappedView

@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
@preconcurrency
@MainActor
internal protocol SupplementaryChildren {
static func supplementaryChildren(_ parent: UnwrappedView) throws -> LazyGroup<SupplementaryView>
}

@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
@MainActor
internal protocol SupplementaryChildrenLabelView: SupplementaryChildren {
static var labelViewPath: String { get }
}
Expand All @@ -62,6 +62,8 @@ extension SupplementaryChildrenLabelView {
}

@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
@MainActor
@preconcurrency
public protocol BaseViewType {
static var typePrefix: String { get }
static var namespacedPrefixes: [String] { get }
Expand Down Expand Up @@ -141,7 +143,7 @@ internal extension ViewType {
// MARK: - Content

@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
public struct Content {
public struct Content: Sendable {
let view: Any
let medium: Medium

Expand All @@ -157,7 +159,7 @@ public struct Content {

@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
internal extension Content {
struct Medium {
struct Medium: Sendable {
let viewModifiers: [Any]
let transitiveViewModifiers: [Any]
let environmentModifiers: [EnvironmentModifier]
Expand Down
5 changes: 5 additions & 0 deletions Sources/ViewInspector/ContentExtraction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ internal struct ContentExtractor {
self.contentSource = try Self.contentSource(from: source)
}

@MainActor
internal func extractContent(environmentObjects: [AnyObject]) throws -> Any {
try validateSourceBeforeExtraction()
switch contentSource {
Expand Down Expand Up @@ -113,6 +114,8 @@ private extension ViewModifier {
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
public extension View {

@preconcurrency
@MainActor
func extractContent(environmentObjects: [AnyObject]) throws -> Any {
var copy = self
environmentObjects.forEach { copy = EnvironmentInjection.inject(environmentObject: $0, into: copy) }
Expand All @@ -129,6 +132,8 @@ public extension View {
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
public extension ViewModifier {

@preconcurrency
@MainActor
func extractContent(environmentObjects: [AnyObject]) throws -> Any {
var copy = self
environmentObjects.forEach { copy = EnvironmentInjection.inject(environmentObject: $0, into: copy) }
Expand Down
1 change: 1 addition & 0 deletions Sources/ViewInspector/InspectableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ extension UnwrappedView {
}

@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
@MainActor
internal protocol UnwrappedView {
var content: Content { get }
var parentView: UnwrappedView? { get }
Expand Down
4 changes: 2 additions & 2 deletions Sources/ViewInspector/InspectionEmissary.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import SwiftUI
import Combine
@preconcurrency import Combine
import XCTest

@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
public protocol InspectionEmissary: AnyObject {
public protocol InspectionEmissary: AnyObject, Sendable {

associatedtype V
var notice: PassthroughSubject<UInt, Never> { get }
Expand Down
1 change: 1 addition & 0 deletions Sources/ViewInspector/Modifiers/AnimationModifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import SwiftUI
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
public extension InspectableView {

@preconcurrency
func callTransaction() throws {
let callback = try modifierAttribute(
modifierName: "_TransactionModifier",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,6 @@ private extension String {
}

private struct FakeNavigationBarItemsKey: PreferenceKey {
static var defaultValue: String = ""
static let defaultValue: String = ""
static func reduce(value: inout String, nextValue: () -> String) { }
}
2 changes: 1 addition & 1 deletion Sources/ViewInspector/PopupPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ internal extension ViewType {

@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
internal extension ViewType {
static var popupContainerTypePrefix = "ViewInspector.ViewType.PopupContainer"
static let popupContainerTypePrefix = "ViewInspector.ViewType.PopupContainer"
}

@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/ActionSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct ActionSheet: KnownViewType {
public static var typePrefix: String = ViewType.PopupContainer<ActionSheet>.typePrefix
public static let typePrefix: String = ViewType.PopupContainer<ActionSheet>.typePrefix
public static var namespacedPrefixes: [String] { [typePrefix] }
public static func inspectionCall(typeName: String) -> String {
return "actionSheet(\(ViewType.indexPlaceholder))"
Expand Down
6 changes: 3 additions & 3 deletions Sources/ViewInspector/SwiftUI/Alert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import SwiftUI
public extension ViewType {

struct Alert: KnownViewType {
public static var typePrefix: String = ViewType.PopupContainer<Alert>.typePrefix
static var typePrefixIOS15: String = "AlertModifier"
public static let typePrefix: String = ViewType.PopupContainer<Alert>.typePrefix
static let typePrefixIOS15: String = "AlertModifier"
public static var namespacedPrefixes: [String] {
[typePrefix, .swiftUINamespaceRegex + typePrefixIOS15]
}
Expand Down Expand Up @@ -222,7 +222,7 @@ extension ViewType.Alert: SupplementaryChildren {
public extension ViewType {

struct AlertButton: KnownViewType {
public static var typePrefix: String = "Alert.Button"
public static let typePrefix: String = "Alert.Button"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/AngularGradient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct AngularGradient: KnownViewType {
public static var typePrefix: String = "AngularGradient"
public static let typePrefix: String = "AngularGradient"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/AnyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct AnyView: KnownViewType {
public static var typePrefix: String = "AnyView"
public static let typePrefix: String = "AnyView"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/AsyncImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct AsyncImage: KnownViewType {
public static var typePrefix: String = "AsyncImage"
public static let typePrefix: String = "AsyncImage"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct Button: KnownViewType {
public static var typePrefix: String = "Button"
public static let typePrefix: String = "Button"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/Canvas.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct Canvas: KnownViewType {
public static var typePrefix: String = "Canvas"
public static let typePrefix: String = "Canvas"
}
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/ViewInspector/SwiftUI/ClassifiedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import SwiftUI
public extension ViewType {

struct ClassifiedView: KnownViewType {
public static var typePrefix: String = ""
public static var isTransitive: Bool { true }
public static let typePrefix: String = ""
public static let isTransitive: Bool = true
}

struct ParentView: KnownViewType {
public static var typePrefix: String = ""
public static let typePrefix: String = ""
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct Color: KnownViewType {
public static var typePrefix: String = "Color"
public static let typePrefix: String = "Color"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/ColorPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct ColorPicker: KnownViewType {
public static var typePrefix: String = "ColorPicker"
public static let typePrefix: String = "ColorPicker"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/ConfirmationDialog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SwiftUI
public extension ViewType {

struct ConfirmationDialog: KnownViewType {
public static var typePrefix: String = "ConfirmationDialogModifier"
public static let typePrefix: String = "ConfirmationDialogModifier"
public static func inspectionCall(typeName: String) -> String {
return "confirmationDialog(\(ViewType.indexPlaceholder))"
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/ViewInspector/SwiftUI/CustomView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,17 @@ public extension InspectableView where View: CustomViewType {
#if os(macOS)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
public extension NSViewRepresentable {
@preconcurrency
@MainActor
func nsView() throws -> NSViewType {
return try ViewHosting.lookup(Self.self)
}
}

@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
public extension NSViewControllerRepresentable {
@preconcurrency
@MainActor
func viewController() throws -> NSViewControllerType {
return try ViewHosting.lookup(Self.self)
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/ViewInspector/SwiftUI/CustomViewModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ internal extension Content {
public extension ViewType {

struct ViewModifierContent: KnownViewType {
public static var typePrefix: String = "_ViewModifier_Content"
public static let typePrefix: String = "_ViewModifier_Content"

public static func inspectionCall(typeName: String) -> String {
return "viewModifierContent(\(ViewType.indexPlaceholder))"
Expand Down Expand Up @@ -161,6 +161,8 @@ internal extension _ViewModifier_Content {

@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
internal extension ViewModifier {
@preconcurrency
@MainActor
func body() -> Any {
body(content: .init())
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/DisclosureGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct DisclosureGroup: KnownViewType {
public static var typePrefix: String = "DisclosureGroup"
public static let typePrefix: String = "DisclosureGroup"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/Divider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct Divider: KnownViewType {
public static var typePrefix: String = "Divider"
public static let typePrefix: String = "Divider"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/EditButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct EditButton: KnownViewType {
public static var typePrefix: String = "EditButton"
public static let typePrefix: String = "EditButton"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/EllipticalGradient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct EllipticalGradient: KnownViewType {
public static var typePrefix: String = "EllipticalGradient"
public static let typePrefix: String = "EllipticalGradient"
}
}

Expand Down
3 changes: 2 additions & 1 deletion Sources/ViewInspector/SwiftUI/EmptyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct EmptyView: KnownViewType {
public static var typePrefix: String = "EmptyView"
public static let typePrefix: String = "EmptyView"
}
}

Expand All @@ -13,6 +13,7 @@ public extension ViewType {
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
public extension InspectableView where View: SingleViewContent {

@preconcurrency
func emptyView() throws -> InspectableView<ViewType.EmptyView> {
return try .init(try child(), parent: self)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ViewInspector/SwiftUI/GeometryReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension ViewType {

struct GeometryReader: KnownViewType {
public static var typePrefix: String = "GeometryReader"
public static let typePrefix: String = "GeometryReader"
}
}

Expand Down
Loading