Skip to content

Commit

Permalink
Vision os (#61)
Browse files Browse the repository at this point in the history
* Update to 5.9 and support visionOS

* Update README
  • Loading branch information
0xLeif authored Jan 11, 2024
1 parent 4f9b3b9 commit d08432f
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.7
// swift-tools-version: 5.9

import PackageDescription

Expand All @@ -8,7 +8,8 @@ let package = Package(
.iOS(.v15),
.watchOS(.v8),
.macOS(.v11),
.tvOS(.v15)
.tvOS(.v15),
.visionOS(.v1)
],
products: [
.library(
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ AppState is a Swift Package that simplifies the management of application state

### Requirements

- Swift 5.7 or later
- Swift 5.9 or later

- iOS 15.0 or later
- watchOS 8.0 or later
- macOS 11.0 or later
- tvOS 15.0 or later
- visionOS 1.0 or later

## Getting Started

Expand Down
2 changes: 1 addition & 1 deletion Sources/AppState/Application/Application+public.swift
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public extension Application {

// MARK: SyncState Functions

@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, *)
@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, visionOS 1.0, *)
public extension Application {
/// Resets the value to the inital value. If the inital value was `nil`, then the value will be removed from `iClouds`
static func reset<Value>(
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppState/Application/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ open class Application: NSObject, ObservableObject {

- Note: Calling `Application.dependency(\.icloudStore).synchronize()` does not force new keys and values to be written to iCloud. Rather, it lets iCloud know that new keys and values are available to be uploaded. Do not rely on your keys and values being available on other devices immediately. The system controls when those keys and values are uploaded. The frequency of upload requests for key-value storage is limited to several per minute.
*/
@objc @available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, *)
@objc @available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, visionOS 1.0, *)
open func didChangeExternally(notification: Notification) {
Application.log(
debug: """
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, *)
@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, visionOS 1.0, *)
extension Application {
/// The default `NSUbiquitousKeyValueStore` instance.
public var icloudStore: Dependency<NSUbiquitousKeyValueStore> {
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppState/PropertyWrappers/SyncState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftUI

- Warning: Avoid using this class for data that is essential to your app’s behavior when offline; instead, store such data directly into the local user defaults database.
*/
@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, *)
@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, visionOS 1.0, *)
@propertyWrapper public struct SyncState<Value: Codable>: DynamicProperty {
/// Holds the singleton instance of `Application`.
@ObservedObject private var app: Application = Application.shared
Expand Down
10 changes: 5 additions & 5 deletions Tests/AppStateTests/SyncStateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SwiftUI
import XCTest
@testable import AppState

@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, *)
@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, visionOS 1.0, *)
fileprivate extension Application {
var syncValue: SyncState<Int?> {
syncState(id: "syncValue")
Expand All @@ -13,19 +13,19 @@ fileprivate extension Application {
}
}

@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, *)
@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, visionOS 1.0, *)
fileprivate struct ExampleSyncValue {
@SyncState(\.syncValue) var count
}


@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, *)
@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, visionOS 1.0, *)
fileprivate struct ExampleFailureSyncValue {
@SyncState(\.syncFailureValue) var count
}


@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, *)
@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, visionOS 1.0, *)
fileprivate class ExampleStoringViewModel: ObservableObject {
@SyncState(\.syncValue) var count

Expand All @@ -40,7 +40,7 @@ fileprivate class ExampleStoringViewModel: ObservableObject {
}


@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, *)
@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, visionOS 1.0, *)
final class SyncStateTests: XCTestCase {
override class func setUp() {
Application
Expand Down

0 comments on commit d08432f

Please sign in to comment.