Skip to content

Commit

Permalink
Raise the minimum supported version of Observable to iOS 17.0.1 (#64)
Browse files Browse the repository at this point in the history
* Raise the minimum supported version to iOS 17.0.1

* Raise watchOS and tvOS
  • Loading branch information
ollieatkinson authored Apr 29, 2024
1 parent 6e49e49 commit 03d51ee
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
18 changes: 9 additions & 9 deletions Sources/Perception/Macros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@
#if canImport(Observation)
import Observation

@available(iOS, deprecated: 17, renamed: "Observable")
@available(iOS, deprecated: 17.0.1, renamed: "Observable")
@available(macOS, deprecated: 14, renamed: "Observable")
@available(tvOS, deprecated: 17, renamed: "Observable")
@available(watchOS, deprecated: 10, renamed: "Observable")
@available(tvOS, deprecated: 17.0.1, renamed: "Observable")
@available(watchOS, deprecated: 10.0.1, renamed: "Observable")
@attached(
member, names: named(_$id), named(_$perceptionRegistrar), named(access), named(withMutation))
@attached(memberAttribute)
@attached(extension, conformances: Observable, Perceptible)
public macro Perceptible() =
#externalMacro(module: "PerceptionMacros", type: "PerceptibleMacro")

@available(iOS, deprecated: 17, renamed: "ObservationTracked")
@available(iOS, deprecated: 17.0.1, renamed: "ObservationTracked")
@available(macOS, deprecated: 14, renamed: "ObservationTracked")
@available(tvOS, deprecated: 17, renamed: "ObservationTracked")
@available(watchOS, deprecated: 10, renamed: "ObservationTracked")
@available(tvOS, deprecated: 17.0.1, renamed: "ObservationTracked")
@available(watchOS, deprecated: 10.0.1, renamed: "ObservationTracked")
@attached(accessor, names: named(init), named(get), named(set))
@attached(peer, names: prefixed(_))
public macro PerceptionTracked() =
#externalMacro(module: "PerceptionMacros", type: "PerceptionTrackedMacro")

@available(iOS, deprecated: 17, renamed: "ObservationIgnored")
@available(iOS, deprecated: 17.0.1, renamed: "ObservationIgnored")
@available(macOS, deprecated: 14, renamed: "ObservationIgnored")
@available(tvOS, deprecated: 17, renamed: "ObservationIgnored")
@available(watchOS, deprecated: 10, renamed: "ObservationIgnored")
@available(tvOS, deprecated: 17.0.1, renamed: "ObservationIgnored")
@available(watchOS, deprecated: 10.0.1, renamed: "ObservationIgnored")
@attached(accessor, names: named(willSet))
public macro PerceptionIgnored() =
#externalMacro(module: "PerceptionMacros", type: "PerceptionIgnoredMacro")
Expand Down
6 changes: 3 additions & 3 deletions Sources/Perception/Perceptible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
/// type doesn't add observation functionality to the type. Instead, always use
/// the ``Perception/Perceptible()`` macro when adding observation
/// support to a type.
@available(iOS, deprecated: 17, renamed: "Observable")
@available(iOS, deprecated: 17.0.1, renamed: "Observable")
@available(macOS, deprecated: 14, renamed: "Observable")
@available(tvOS, deprecated: 17, renamed: "Observable")
@available(watchOS, deprecated: 10, renamed: "Observable")
@available(tvOS, deprecated: 17.0.1, renamed: "Observable")
@available(watchOS, deprecated: 10.0.1, renamed: "Observable")
public protocol Perceptible {}
32 changes: 16 additions & 16 deletions Sources/Perception/PerceptionRegistrar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import SwiftUI
///
/// You don't need to create an instance of `PerceptionRegistrar` when using
/// the ``Perception/Perceptible()`` macro to indicate observability of a type.
@available(iOS, deprecated: 17, renamed: "ObservationRegistrar")
@available(iOS, deprecated: 17.0.1, renamed: "ObservationRegistrar")
@available(macOS, deprecated: 14, renamed: "ObservationRegistrar")
@available(tvOS, deprecated: 17, renamed: "ObservationRegistrar")
@available(watchOS, deprecated: 10, renamed: "ObservationRegistrar")
@available(tvOS, deprecated: 17.0.1, renamed: "ObservationRegistrar")
@available(watchOS, deprecated: 10.0.1, renamed: "ObservationRegistrar")
public struct PerceptionRegistrar: Sendable {
private let _rawValue: AnySendable
#if DEBUG
Expand All @@ -27,7 +27,7 @@ public struct PerceptionRegistrar: Sendable {
/// ``Perception/Perceptible()`` macro to indicate observably
/// of a type.
public init(isPerceptionCheckingEnabled: Bool = Perception.isPerceptionCheckingEnabled) {
if #available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) {
if #available(iOS 17.0.1, macOS 14, tvOS 17.0.1, watchOS 10.0.1, *) {
#if canImport(Observation)
self._rawValue = AnySendable(ObservationRegistrar())
#else
Expand All @@ -42,7 +42,7 @@ public struct PerceptionRegistrar: Sendable {
}

#if canImport(Observation)
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
@available(iOS 17.0.1, macOS 14, tvOS 17.0.1, watchOS 10.0.1, *)
private var registrar: ObservationRegistrar {
self._rawValue.base as! ObservationRegistrar
}
Expand All @@ -54,7 +54,7 @@ public struct PerceptionRegistrar: Sendable {
}

#if canImport(Observation)
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
@available(iOS 17.0.1, macOS 14, tvOS 17.0.1, watchOS 10.0.1, *)
extension PerceptionRegistrar {
public func access<Subject: Observable, Member>(
_ subject: Subject, keyPath: KeyPath<Subject, Member>
Expand Down Expand Up @@ -94,7 +94,7 @@ extension PerceptionRegistrar {
self.perceptionCheck(file: file, line: line)
#endif
#if canImport(Observation)
if #available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) {
if #available(iOS 17.0.1, macOS 14, tvOS 17.0.1, watchOS 10.0.1, *) {
func `open`<T: Observable>(_ subject: T) {
self.registrar.access(
subject,
Expand All @@ -117,7 +117,7 @@ extension PerceptionRegistrar {
_ mutation: () throws -> T
) rethrows -> T {
#if canImport(Observation)
if #available(iOS 17, macOS 14, tvOS 17, watchOS 10, *),
if #available(iOS 17.0.1, macOS 14, tvOS 17.0.1, watchOS 10.0.1, *),
let subject = subject as? any Observable
{
func `open`<S: Observable>(_ subject: S) throws -> T {
Expand All @@ -142,7 +142,7 @@ extension PerceptionRegistrar {
keyPath: KeyPath<Subject, Member>
) {
#if canImport(Observation)
if #available(iOS 17, macOS 14, tvOS 17, watchOS 10, *),
if #available(iOS 17.0.1, macOS 14, tvOS 17.0.1, watchOS 10.0.1, *),
let subject = subject as? any Observable
{
func `open`<S: Observable>(_ subject: S) {
Expand All @@ -164,7 +164,7 @@ extension PerceptionRegistrar {
keyPath: KeyPath<Subject, Member>
) {
#if canImport(Observation)
if #available(iOS 17, macOS 14, tvOS 17, watchOS 10, *),
if #available(iOS 17.0.1, macOS 14, tvOS 17.0.1, watchOS 10.0.1, *),
let subject = subject as? any Observable
{
func `open`<S: Observable>(_ subject: S) {
Expand Down Expand Up @@ -315,10 +315,10 @@ extension PerceptionRegistrar: Hashable {
#endif

#if DEBUG
@available(iOS, deprecated: 17)
@available(iOS, deprecated: 17.0.1)
@available(macOS, deprecated: 14)
@available(tvOS, deprecated: 17)
@available(watchOS, deprecated: 10)
@available(tvOS, deprecated: 17.0.1)
@available(watchOS, deprecated: 10.0.1)
public func _withoutPerceptionChecking<T>(
_ apply: () -> T
) -> T {
Expand All @@ -327,10 +327,10 @@ extension PerceptionRegistrar: Hashable {
}
}
#else
@available(iOS, deprecated: 17)
@available(iOS, deprecated: 17.0.1)
@available(macOS, deprecated: 14)
@available(tvOS, deprecated: 17)
@available(watchOS, deprecated: 10)
@available(tvOS, deprecated: 17.0.1)
@available(watchOS, deprecated: 10.0.1)
@_transparent
@inline(__always)
public func _withoutPerceptionChecking<T>(
Expand Down
8 changes: 4 additions & 4 deletions Sources/Perception/PerceptionTracking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,16 @@ private func generateAccessList<T>(_ apply: () -> T) -> (T, PerceptionTracking._
///
/// - Returns: The value that the `apply` closure returns if it has a return
/// value; otherwise, there is no return value.
@available(iOS, deprecated: 17, renamed: "withObservationTracking")
@available(iOS, deprecated: 17.0.1, renamed: "withObservationTracking")
@available(macOS, deprecated: 14, renamed: "withObservationTracking")
@available(tvOS, deprecated: 17, renamed: "withObservationTracking")
@available(watchOS, deprecated: 10, renamed: "withObservationTracking")
@available(tvOS, deprecated: 17.0.1, renamed: "withObservationTracking")
@available(watchOS, deprecated: 10.0.1, renamed: "withObservationTracking")
public func withPerceptionTracking<T>(
_ apply: () -> T,
onChange: @autoclosure () -> @Sendable () -> Void
) -> T {
#if canImport(Observation)
if #available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) {
if #available(iOS 17.0.1, macOS 14, tvOS 17.0.1, watchOS 10.0.1, *) {
return withObservationTracking(apply, onChange: onChange())
}
#endif
Expand Down
14 changes: 7 additions & 7 deletions Sources/Perception/WithPerceptionTracking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ import SwiftUI
/// To debug this, expand the warning in the Issue Navigator of Xcode (cmd+5), and click through the
/// stack frames displayed to find the line in your view where you are accessing state without being
/// inside ``WithPerceptionTracking``.
@available(iOS, deprecated: 17, message: "Remove WithPerceptionTracking")
@available(iOS, deprecated: 17.0.1, message: "Remove WithPerceptionTracking")
@available(macOS, deprecated: 14, message: "Remove WithPerceptionTracking")
@available(tvOS, deprecated: 17, message: "Remove WithPerceptionTracking")
@available(watchOS, deprecated: 10, message: "Remove WithPerceptionTracking")
@available(tvOS, deprecated: 17.0.1, message: "Remove WithPerceptionTracking")
@available(watchOS, deprecated: 10.0.1, message: "Remove WithPerceptionTracking")
public struct WithPerceptionTracking<Content> {
@State var id = 0
let content: () -> Content

public var body: Content {
if #available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) {
if #available(iOS 17.0.1, macOS 14, tvOS 17.0.1, watchOS 10.0.1, *) {
return self.instrumentedBody()
} else {
// NB: View will not re-render when 'id' changes unless we access it in the view.
Expand Down Expand Up @@ -156,10 +156,10 @@ extension WithPerceptionTracking: View where Content: View {
}
}

@available(iOS, deprecated: 17)
@available(iOS, deprecated: 17.0.1)
@available(macOS, deprecated: 14)
@available(tvOS, deprecated: 17)
@available(watchOS, deprecated: 10)
@available(tvOS, deprecated: 17.0.1)
@available(watchOS, deprecated: 10.0.1)
public enum _PerceptionLocals {
@TaskLocal public static var isInPerceptionTracking = false
@TaskLocal public static var skipPerceptionChecking = false
Expand Down
2 changes: 1 addition & 1 deletion Sources/PerceptionMacros/PerceptibleMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ extension PerceptibleMacro: ExtensionMacro {
extension \(raw: type.trimmedDescription): \(raw: qualifiedConformanceName) {}
"""
let obsDecl: DeclSyntax = """
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
@available(iOS 17.0.1, macOS 14, tvOS 17.0.1, watchOS 10.0.1, *)
extension \(raw: type.trimmedDescription): Observation.Observable {}
"""
let ext = decl.cast(ExtensionDeclSyntax.self)
Expand Down

0 comments on commit 03d51ee

Please sign in to comment.