Skip to content

Commit 53c895b

Browse files
committed
Support visionOS
1 parent 99faa08 commit 53c895b

File tree

8 files changed

+37
-20
lines changed

8 files changed

+37
-20
lines changed

.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.9
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

66
let package = Package(
77
name: "EasyStash",
8+
platforms: [
9+
.iOS(.v15),
10+
.tvOS(.v13),
11+
.macOS(.v12),
12+
],
813
products: [
914
.library(
1015
name: "EasyStash",
1116
targets: ["EasyStash"]
1217
),
1318
],
14-
dependencies: [
15-
],
19+
dependencies: [],
1620
targets: [
1721
.target(
1822
name: "EasyStash",

Sources/Options.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public struct Options {
2121

2222
public init() {
2323
#if os(tvOS)
24-
searchPathDirectory = .cachesDirectory
24+
searchPathDirectory = .cachesDirectory
2525
#else
26-
searchPathDirectory = .applicationSupportDirectory
26+
searchPathDirectory = .applicationSupportDirectory
2727
#endif
2828
}
2929
}

Sources/Storage+Codable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public extension Storage {
2222
}
2323

2424
func load<T: Codable>(forKey key: String, as: T.Type, withExpiry expiry: Expiry = .never) throws -> T {
25-
func loadFromDisk<T: Codable>(forKey key: String, as: T.Type) throws -> T {
25+
func loadFromDisk(forKey key: String, as: T.Type) throws -> T {
2626
let data = try Data(contentsOf: fileUrl(forKey: key))
2727
let decoder = options.decoder
2828

Sources/Storage+Image.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
//
88

99
#if canImport(UIKit)
10-
import UIKit
10+
import UIKit
1111
#elseif canImport(AppKit)
12-
import AppKit
12+
import AppKit
1313
#endif
1414

1515
public extension Storage {

Sources/Utils.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
//
88

99
import Foundation
10+
1011
#if canImport(UIKit)
11-
import UIKit
12-
public typealias Image = UIImage
12+
import UIKit
13+
public typealias Image = UIImage
1314
#elseif canImport(AppKit)
14-
import AppKit
15-
public typealias Image = NSImage
15+
import AppKit
16+
public typealias Image = NSImage
1617
#endif
1718

1819
func unwrapOrThrow<T>(_ optional: Optional<T>, _ error: Error) throws -> T {
@@ -47,21 +48,21 @@ public struct TypeWrapper<T: Codable>: Codable {
4748
class Utils {
4849
static func image(data: Data) -> Image? {
4950
#if canImport(UIKit)
50-
return UIImage(data: data)
51+
return UIImage(data: data)
5152
#elseif canImport(AppKit)
52-
return NSImage(data: data)
53+
return NSImage(data: data)
5354
#else
54-
return nil
55+
return nil
5556
#endif
5657
}
5758

5859
static func data(image: Image) -> Data? {
5960
#if canImport(UIKit)
60-
return image.jpegData(compressionQuality: 0.9)
61+
return image.jpegData(compressionQuality: 0.9)
6162
#elseif canImport(AppKit)
62-
return image.tiffRepresentation
63+
return image.tiffRepresentation
6364
#else
64-
return nil
65+
return nil
6566
#endif
6667
}
6768
}

Tests/EasyStashTests/ImageGenerate.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2019 Khoa Pham. All rights reserved.
77
//
88

9-
#if os(iOS) || os(tvOS)
9+
#if os(iOS) || os(tvOS) || os(visionOS)
1010
import UIKit
1111

1212
extension UIColor {
@@ -21,6 +21,7 @@ extension UIColor {
2121
}
2222
}
2323
}
24+
2425
#elseif os(OSX)
2526
import AppKit
2627

Tests/EasyStashTests/iOSTests.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ class iOSTests: XCTestCase {
181181
func testPerformanceUsingKeyArchiver() {
182182
let users = Array(0..<10_000).map { _ in User3(city: "Oslo", name: "A") }
183183
measure {
184-
NSKeyedArchiver.archivedData(withRootObject: users)
184+
do {
185+
try NSKeyedArchiver.archivedData(withRootObject: users, requiringSecureCoding: false)
186+
} catch {
187+
188+
}
185189
}
186190
}
187191
}

0 commit comments

Comments
 (0)