Skip to content

Commit f377c32

Browse files
committed
Clean up and add watchOS support
1 parent 81fc4e5 commit f377c32

File tree

14 files changed

+347
-58
lines changed

14 files changed

+347
-58
lines changed

Cache.podspec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ Pod::Spec.new do |s|
88
s.source = { :git => "https://github.com/hyperoslo/Cache.git", :tag => s.version.to_s }
99
s.social_media_url = 'https://twitter.com/hyperoslo'
1010

11-
s.ios.deployment_target = '11.0'
12-
s.osx.deployment_target = '10.12'
13-
s.tvos.deployment_target = '11.0'
11+
s.ios.deployment_target = '12.0'
12+
s.osx.deployment_target = '10.14'
13+
s.tvos.deployment_target = '12.0'
14+
s.watchos.deployment_target = '6.0'
1415

1516
s.requires_arc = true
1617
s.ios.source_files = 'Source/{iOS,Shared}/**/*'

Cache.xcodeproj/project.pbxproj

Lines changed: 322 additions & 25 deletions
Large diffs are not rendered by default.

Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1200"
3+
LastUpgradeVersion = "1530"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Cache.xcodeproj/xcshareddata/xcschemes/Cache-macOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1200"
3+
LastUpgradeVersion = "1530"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Cache.xcodeproj/xcshareddata/xcschemes/Cache-tvOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1200"
3+
LastUpgradeVersion = "1530"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Source/Shared/Configuration/DiskConfig.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ public struct DiskConfig {
1010
public let maxSize: UInt
1111
/// A folder to store the disk cache contents. Defaults to a prefixed directory in Caches if nil
1212
public let directory: URL?
13-
#if os(iOS) || os(tvOS)
1413
/// Data protection is used to store files in an encrypted format on disk and to decrypt them on demand.
15-
/// Support only on iOS and tvOS.
1614
public let protectionType: FileProtectionType?
1715

1816
public init(name: String, expiry: Expiry = .never,
@@ -24,13 +22,4 @@ public struct DiskConfig {
2422
self.directory = directory
2523
self.protectionType = protectionType
2624
}
27-
#else
28-
public init(name: String, expiry: Expiry = .never,
29-
maxSize: UInt = 0, directory: URL? = nil) {
30-
self.name = name
31-
self.expiry = expiry
32-
self.maxSize = maxSize
33-
self.directory = directory
34-
}
35-
#endif
3625
}

Source/Shared/Library/ImageWrapper.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
#if canImport(UIKit)
2+
import UIKit
3+
#endif
4+
15
import Foundation
26

3-
#if os(iOS) || os(tvOS) || os(macOS)
47
public struct ImageWrapper: Codable {
58
public let image: Image
69

@@ -31,4 +34,3 @@ public struct ImageWrapper: Codable {
3134
try container.encode(data, forKey: CodingKeys.image)
3235
}
3336
}
34-
#endif

Source/Shared/Library/TransformerFactory.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#if canImport(UIKit)
2+
import UIKit
3+
#endif
4+
15
import Foundation
26

37
public class TransformerFactory {
@@ -9,7 +13,6 @@ public class TransformerFactory {
913
return Transformer<Data>(toData: toData, fromData: fromData)
1014
}
1115

12-
#if os(iOS) || os(tvOS) || os(macOS) || os(visionOS)
1316
public static func forImage() -> Transformer<Image> {
1417
let toData: (Image) throws -> Data = { image in
1518
return try image.cache_toData().unwrapOrThrow(error: StorageError.transformerFail)
@@ -21,7 +24,6 @@ public class TransformerFactory {
2124

2225
return Transformer<Image>(toData: toData, fromData: fromData)
2326
}
24-
#endif
2527

2628
public static func forCodable<U: Codable>(ofType: U.Type) -> Transformer<U> {
2729
let toData: (U) throws -> Data = { object in

Source/Shared/Library/Types.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#if os(iOS) || os(tvOS) || os(visionOS)
1+
#if canImport(UIKit)
22
import UIKit
33
public typealias Image = UIImage
4-
#elseif os(watchOS)
54

65
#elseif os(OSX)
76
import AppKit

Source/Shared/Storage/DiskStorage.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,11 @@ final public class DiskStorage<Key: Hashable, Value> {
3939

4040
try createDirectory()
4141

42-
// protection
43-
#if os(iOS) || os(tvOS)
4442
if let protectionType = config.protectionType {
4543
try setDirectoryAttributes([
4644
FileAttributeKey.protectionKey: protectionType
4745
])
4846
}
49-
#endif
5047
}
5148

5249
public required init(config: DiskConfig, fileManager: FileManager = FileManager.default, path: String, transformer: Transformer<Value>) {

0 commit comments

Comments
 (0)