From 3116f50bdc5ec2dd2188f6193497e51a8f62d817 Mon Sep 17 00:00:00 2001 From: Igor Skovorodkin Date: Thu, 13 May 2021 16:03:07 +0300 Subject: [PATCH 01/31] watchOS support --- Cache.podspec | 2 + Cache.xcodeproj/project.pbxproj | 208 ++++++++++++++++++ Source/Shared/Configuration/DiskConfig.swift | 2 +- Source/Shared/Library/ImageWrapper.swift | 2 +- .../Shared/Library/TransformerFactory.swift | 2 +- Source/Shared/Library/Types.swift | 2 +- Source/Shared/Storage/DiskStorage.swift | 2 +- Source/Shared/Storage/Storage+Transform.swift | 2 +- SupportFiles/watchOS/Info.plist | 22 ++ 9 files changed, 238 insertions(+), 6 deletions(-) create mode 100644 SupportFiles/watchOS/Info.plist diff --git a/Cache.podspec b/Cache.podspec index 6d31d0b4..9dfb6483 100644 --- a/Cache.podspec +++ b/Cache.podspec @@ -11,11 +11,13 @@ Pod::Spec.new do |s| s.ios.deployment_target = '11.0' s.osx.deployment_target = '10.12' s.tvos.deployment_target = '11.0' + s.watchos.deployment_target = '5.0' s.requires_arc = true s.ios.source_files = 'Source/{iOS,Shared}/**/*' s.osx.source_files = 'Source/{Mac,Shared}/**/*' s.tvos.source_files = 'Source/{iOS,Shared}/**/*' + s.watchos.source_files = 'Source/{iOS,Shared}/**/*' s.frameworks = 'Foundation' s.swift_version = '5.0' diff --git a/Cache.xcodeproj/project.pbxproj b/Cache.xcodeproj/project.pbxproj index 05475ed1..64d3441a 100644 --- a/Cache.xcodeproj/project.pbxproj +++ b/Cache.xcodeproj/project.pbxproj @@ -150,6 +150,40 @@ D5A9D1C321144B65005DBD3F /* StorageObservationRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9D1C221144B65005DBD3F /* StorageObservationRegistry.swift */; }; D5A9D1C421144B65005DBD3F /* StorageObservationRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9D1C221144B65005DBD3F /* StorageObservationRegistry.swift */; }; D5A9D1C521144B65005DBD3F /* StorageObservationRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9D1C221144B65005DBD3F /* StorageObservationRegistry.swift */; }; + F812FB77264D57BC00D179F5 /* MemoryConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF984E1F694FFA00CE8F68 /* MemoryConfig.swift */; }; + F812FB78264D57BC00D179F5 /* DiskConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF984D1F694FFA00CE8F68 /* DiskConfig.swift */; }; + F812FB79264D57BC00D179F5 /* Date+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98501F694FFA00CE8F68 /* Date+Extensions.swift */; }; + F812FB7A264D57BC00D179F5 /* Hasher+constantAccrossExecutions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E791649250E2AA500A71666 /* Hasher+constantAccrossExecutions.swift */; }; + F812FB7B264D57BC00D179F5 /* JSONDecoder+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28897041F8B79B300C61DEE /* JSONDecoder+Extensions.swift */; }; + F812FB7C264D57BC00D179F5 /* URL+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2292AB7A252A14520031F3B9 /* URL+Extensions.swift */; }; + F812FB7D264D57BC00D179F5 /* FileManager+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2292AB84252A14F50031F3B9 /* FileManager+Extensions.swift */; }; + F812FB7E264D57C300D179F5 /* TransformerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27014A420D129EB003B45C7 /* TransformerFactory.swift */; }; + F812FB7F264D57C300D179F5 /* Optional+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270148B20D113EA003B45C7 /* Optional+Extension.swift */; }; + F812FB80264D57C300D179F5 /* JSONDictionaryWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D4CC1F1FA3411300E4A2D5 /* JSONDictionaryWrapper.swift */; }; + F812FB81264D57C300D179F5 /* ExpirationMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98551F694FFA00CE8F68 /* ExpirationMode.swift */; }; + F812FB82264D57C300D179F5 /* ImageWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98571F694FFA00CE8F68 /* ImageWrapper.swift */; }; + F812FB83264D57C300D179F5 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98861F695B8F00CE8F68 /* Types.swift */; }; + F812FB84264D57C300D179F5 /* StorageError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98591F694FFA00CE8F68 /* StorageError.swift */; }; + F812FB85264D57C300D179F5 /* JSONArrayWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D4CC231FA3426B00E4A2D5 /* JSONArrayWrapper.swift */; }; + F812FB86264D57C300D179F5 /* TypeWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270148F20D1251E003B45C7 /* TypeWrapper.swift */; }; + F812FB87264D57C300D179F5 /* ObservationToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9D1B621134547005DBD3F /* ObservationToken.swift */; }; + F812FB88264D57C300D179F5 /* Entry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D221E5BF20D00DCC00BC940E /* Entry.swift */; }; + F812FB89264D57C300D179F5 /* MemoryCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270149320D125AC003B45C7 /* MemoryCapsule.swift */; }; + F812FB8A264D57C300D179F5 /* DataSerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98531F694FFA00CE8F68 /* DataSerializer.swift */; }; + F812FB8B264D57C300D179F5 /* Expiry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98561F694FFA00CE8F68 /* Expiry.swift */; }; + F812FB8C264D57C300D179F5 /* MD5.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D4CC151FA3145000E4A2D5 /* MD5.swift */; }; + F812FB8D264D57C300D179F5 /* Transformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270146F20D1018A003B45C7 /* Transformer.swift */; }; + F812FB8E264D57C800D179F5 /* Storage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270147F20D10982003B45C7 /* Storage.swift */; }; + F812FB8F264D57C800D179F5 /* StorageObservationRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9D1C221144B65005DBD3F /* StorageObservationRegistry.swift */; }; + F812FB90264D57C800D179F5 /* HybridStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270147720D1046A003B45C7 /* HybridStorage.swift */; }; + F812FB91264D57C800D179F5 /* SyncStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270147B20D107DA003B45C7 /* SyncStorage.swift */; }; + F812FB92264D57C800D179F5 /* MemoryStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D221E5BB20D00D9300BC940E /* MemoryStorage.swift */; }; + F812FB93264D57C800D179F5 /* KeyObservationRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D51146522118337500197DCE /* KeyObservationRegistry.swift */; }; + F812FB94264D57C800D179F5 /* AsyncStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270148320D10E76003B45C7 /* AsyncStorage.swift */; }; + F812FB95264D57C800D179F5 /* Storage+Transform.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270148720D11040003B45C7 /* Storage+Transform.swift */; }; + F812FB96264D57C800D179F5 /* DiskStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D221E5C320D00DDB00BC940E /* DiskStorage.swift */; }; + F812FB97264D57C800D179F5 /* StorageAware.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270147320D101F3003B45C7 /* StorageAware.swift */; }; + F812FB98264D57CC00D179F5 /* UIImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A138C01EB29BFA00881A20 /* UIImage+Extensions.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -245,6 +279,9 @@ D5A9D1C221144B65005DBD3F /* StorageObservationRegistry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageObservationRegistry.swift; sourceTree = ""; }; D5DC59E01C20593E003BD79B /* Cache.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cache.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EBAACA991FBC369300FA206E /* SimpleStorage.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = SimpleStorage.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + F812FB6F264D579E00D179F5 /* Cache_watchOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cache_watchOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + F812FB71264D579E00D179F5 /* Cache_watchOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Cache_watchOS.h; sourceTree = ""; }; + F812FB72264D579E00D179F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -293,6 +330,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + F812FB6C264D579E00D179F5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -503,6 +547,7 @@ D5643E341C43F2CC00582E17 /* Playgrounds */, D5291C081C28220B00B702C9 /* Source */, D5DC59FA1C205AC9003BD79B /* Tests */, + F812FB70264D579E00D179F5 /* Cache-watchOS */, D5DC59E11C20593E003BD79B /* Products */, ); indentWidth = 4; @@ -518,6 +563,7 @@ D5291D691C283B5400B702C9 /* Cache-Mac-Tests.xctest */, BDEDD3561DBCE5B1007416A6 /* Cache.framework */, BDEDD3781DBCEB8A007416A6 /* Cache-tvOS-Tests.xctest */, + F812FB6F264D579E00D179F5 /* Cache_watchOS.framework */, ); name = Products; sourceTree = ""; @@ -532,6 +578,15 @@ path = Tests; sourceTree = ""; }; + F812FB70264D579E00D179F5 /* Cache-watchOS */ = { + isa = PBXGroup; + children = ( + F812FB71264D579E00D179F5 /* Cache_watchOS.h */, + F812FB72264D579E00D179F5 /* Info.plist */, + ); + path = "Cache-watchOS"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -556,6 +611,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + F812FB6A264D579E00D179F5 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ @@ -667,6 +729,24 @@ productReference = D5DC59E01C20593E003BD79B /* Cache.framework */; productType = "com.apple.product-type.framework"; }; + F812FB6E264D579E00D179F5 /* Cache-watchOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = F812FB76264D579E00D179F5 /* Build configuration list for PBXNativeTarget "Cache-watchOS" */; + buildPhases = ( + F812FB6A264D579E00D179F5 /* Headers */, + F812FB6B264D579E00D179F5 /* Sources */, + F812FB6C264D579E00D179F5 /* Frameworks */, + F812FB6D264D579E00D179F5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Cache-watchOS"; + productName = "Cache-watchOS"; + productReference = F812FB6F264D579E00D179F5 /* Cache_watchOS.framework */; + productType = "com.apple.product-type.framework"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -700,6 +780,10 @@ CreatedOnToolsVersion = 7.2; LastSwiftMigration = 0800; }; + F812FB6E264D579E00D179F5 = { + CreatedOnToolsVersion = 12.5; + ProvisioningStyle = Manual; + }; }; }; buildConfigurationList = D5DC59DA1C20593E003BD79B /* Build configuration list for PBXProject "Cache" */; @@ -721,6 +805,7 @@ D5291D681C283B5400B702C9 /* Cache-Mac-Tests */, BDEDD3551DBCE5B1007416A6 /* Cache-tvOS */, BDEDD3771DBCEB8A007416A6 /* Cache-tvOS-Tests */, + F812FB6E264D579E00D179F5 /* Cache-watchOS */, ); }; /* End PBXProject section */ @@ -768,6 +853,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + F812FB6D264D579E00D179F5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -953,6 +1045,47 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + F812FB6B264D579E00D179F5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F812FB95264D57C800D179F5 /* Storage+Transform.swift in Sources */, + F812FB81264D57C300D179F5 /* ExpirationMode.swift in Sources */, + F812FB82264D57C300D179F5 /* ImageWrapper.swift in Sources */, + F812FB78264D57BC00D179F5 /* DiskConfig.swift in Sources */, + F812FB8A264D57C300D179F5 /* DataSerializer.swift in Sources */, + F812FB8D264D57C300D179F5 /* Transformer.swift in Sources */, + F812FB8E264D57C800D179F5 /* Storage.swift in Sources */, + F812FB7D264D57BC00D179F5 /* FileManager+Extensions.swift in Sources */, + F812FB8B264D57C300D179F5 /* Expiry.swift in Sources */, + F812FB92264D57C800D179F5 /* MemoryStorage.swift in Sources */, + F812FB7C264D57BC00D179F5 /* URL+Extensions.swift in Sources */, + F812FB80264D57C300D179F5 /* JSONDictionaryWrapper.swift in Sources */, + F812FB96264D57C800D179F5 /* DiskStorage.swift in Sources */, + F812FB88264D57C300D179F5 /* Entry.swift in Sources */, + F812FB89264D57C300D179F5 /* MemoryCapsule.swift in Sources */, + F812FB8C264D57C300D179F5 /* MD5.swift in Sources */, + F812FB7B264D57BC00D179F5 /* JSONDecoder+Extensions.swift in Sources */, + F812FB91264D57C800D179F5 /* SyncStorage.swift in Sources */, + F812FB87264D57C300D179F5 /* ObservationToken.swift in Sources */, + F812FB97264D57C800D179F5 /* StorageAware.swift in Sources */, + F812FB85264D57C300D179F5 /* JSONArrayWrapper.swift in Sources */, + F812FB7F264D57C300D179F5 /* Optional+Extension.swift in Sources */, + F812FB8F264D57C800D179F5 /* StorageObservationRegistry.swift in Sources */, + F812FB83264D57C300D179F5 /* Types.swift in Sources */, + F812FB90264D57C800D179F5 /* HybridStorage.swift in Sources */, + F812FB77264D57BC00D179F5 /* MemoryConfig.swift in Sources */, + F812FB93264D57C800D179F5 /* KeyObservationRegistry.swift in Sources */, + F812FB84264D57C300D179F5 /* StorageError.swift in Sources */, + F812FB7A264D57BC00D179F5 /* Hasher+constantAccrossExecutions.swift in Sources */, + F812FB94264D57C800D179F5 /* AsyncStorage.swift in Sources */, + F812FB7E264D57C300D179F5 /* TransformerFactory.swift in Sources */, + F812FB98264D57CC00D179F5 /* UIImage+Extensions.swift in Sources */, + F812FB79264D57BC00D179F5 /* Date+Extensions.swift in Sources */, + F812FB86264D57C300D179F5 /* TypeWrapper.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -1320,6 +1453,72 @@ }; name = Release; }; + F812FB74264D579E00D179F5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Manual; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = "$(SRCROOT)/SupportFiles/watchOS/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-watchOS"; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SDKROOT = watchos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 5.0; + }; + name = Debug; + }; + F812FB75264D579E00D179F5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Manual; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = "$(SRCROOT)/SupportFiles/watchOS/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-watchOS"; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SDKROOT = watchos; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 5.0; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -1386,6 +1585,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + F812FB76264D579E00D179F5 /* Build configuration list for PBXNativeTarget "Cache-watchOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F812FB74264D579E00D179F5 /* Debug */, + F812FB75264D579E00D179F5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = D5DC59D71C20593E003BD79B /* Project object */; diff --git a/Source/Shared/Configuration/DiskConfig.swift b/Source/Shared/Configuration/DiskConfig.swift index 3d0a01c5..e57212a3 100644 --- a/Source/Shared/Configuration/DiskConfig.swift +++ b/Source/Shared/Configuration/DiskConfig.swift @@ -10,7 +10,7 @@ public struct DiskConfig { public let maxSize: UInt /// A folder to store the disk cache contents. Defaults to a prefixed directory in Caches if nil public let directory: URL? - #if os(iOS) || os(tvOS) + #if os(iOS) || os(tvOS) || os(watchOS) /// Data protection is used to store files in an encrypted format on disk and to decrypt them on demand. /// Support only on iOS and tvOS. public let protectionType: FileProtectionType? diff --git a/Source/Shared/Library/ImageWrapper.swift b/Source/Shared/Library/ImageWrapper.swift index cc9fd7d7..5bc0cdde 100644 --- a/Source/Shared/Library/ImageWrapper.swift +++ b/Source/Shared/Library/ImageWrapper.swift @@ -1,6 +1,6 @@ import Foundation -#if os(iOS) || os(tvOS) || os(macOS) +#if os(iOS) || os(tvOS) || os(macOS) || os(watchOS) public struct ImageWrapper: Codable { public let image: Image diff --git a/Source/Shared/Library/TransformerFactory.swift b/Source/Shared/Library/TransformerFactory.swift index 00e4fe9a..e10a212e 100644 --- a/Source/Shared/Library/TransformerFactory.swift +++ b/Source/Shared/Library/TransformerFactory.swift @@ -9,7 +9,7 @@ public class TransformerFactory { return Transformer(toData: toData, fromData: fromData) } - #if os(iOS) || os(tvOS) || os(macOS) + #if os(iOS) || os(tvOS) || os(macOS) || os(watchOS) public static func forImage() -> Transformer { let toData: (Image) throws -> Data = { image in return try image.cache_toData().unwrapOrThrow(error: StorageError.transformerFail) diff --git a/Source/Shared/Library/Types.swift b/Source/Shared/Library/Types.swift index 81e7a301..caf74563 100644 --- a/Source/Shared/Library/Types.swift +++ b/Source/Shared/Library/Types.swift @@ -1,4 +1,4 @@ -#if os(iOS) || os(tvOS) +#if os(iOS) || os(tvOS) || os(watchOS) import UIKit public typealias Image = UIImage #elseif os(watchOS) diff --git a/Source/Shared/Storage/DiskStorage.swift b/Source/Shared/Storage/DiskStorage.swift index 76f4cd02..78adad54 100644 --- a/Source/Shared/Storage/DiskStorage.swift +++ b/Source/Shared/Storage/DiskStorage.swift @@ -40,7 +40,7 @@ final public class DiskStorage { try createDirectory() // protection - #if os(iOS) || os(tvOS) + #if os(iOS) || os(tvOS) || os(watchOS) if let protectionType = config.protectionType { try setDirectoryAttributes([ FileAttributeKey.protectionKey: protectionType diff --git a/Source/Shared/Storage/Storage+Transform.swift b/Source/Shared/Storage/Storage+Transform.swift index 494e6afb..af1bc366 100644 --- a/Source/Shared/Storage/Storage+Transform.swift +++ b/Source/Shared/Storage/Storage+Transform.swift @@ -7,7 +7,7 @@ public extension Storage { } - #if os(iOS) || os(tvOS) || os(macOS) + #if os(iOS) || os(tvOS) || os(macOS) || os(watchOS) func transformImage() -> Storage { let storage = transform(transformer: TransformerFactory.forImage()) return storage diff --git a/SupportFiles/watchOS/Info.plist b/SupportFiles/watchOS/Info.plist new file mode 100644 index 00000000..37f13eb0 --- /dev/null +++ b/SupportFiles/watchOS/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + + From 5766a61ec509eac4c8081d109dacd2ca41391f4a Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Wed, 2 Jun 2021 10:01:43 +0200 Subject: [PATCH 02/31] Update Hasher+constantAccrossExecutions.swift Add original license to file header in order to comply to FOSS --- .../Hasher+constantAccrossExecutions.swift | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Source/Shared/Extensions/Hasher+constantAccrossExecutions.swift b/Source/Shared/Extensions/Hasher+constantAccrossExecutions.swift index 1406a54f..37d0feee 100644 --- a/Source/Shared/Extensions/Hasher+constantAccrossExecutions.swift +++ b/Source/Shared/Extensions/Hasher+constantAccrossExecutions.swift @@ -1,3 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// +/// This file implements SipHash-2-4 and SipHash-1-3 +/// (https://131002.net/siphash/). +/// +/// This file is based on the reference C implementation, which was released +/// to public domain by: +/// +/// * Jean-Philippe Aumasson +/// * Daniel J. Bernstein +//===----------------------------------------------------------------------===// import Foundation From 9efca9d8017c6c866ac146f82a1637c82c50755f Mon Sep 17 00:00:00 2001 From: Alexey Ivashko Date: Tue, 8 Jun 2021 12:31:12 +0300 Subject: [PATCH 03/31] Fix SPM warning in Xcode 13b1 --- Package.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index c6fcee49..c167e646 100644 --- a/Package.swift +++ b/Package.swift @@ -13,8 +13,8 @@ let package = Package( targets: [ .target( name: "Cache", - path: "Source", - exclude: ["Library/ImageWrapper.swift"]), + path: "Source" + ), .testTarget( name: "CacheTests", dependencies: ["Cache"], From 033457ce946725e7d8c9ed47fbd19c5f74282312 Mon Sep 17 00:00:00 2001 From: Abdullah Alhaider Date: Wed, 8 Dec 2021 13:01:51 +0500 Subject: [PATCH 04/31] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 137c354f..45afb49e 100644 --- a/README.md +++ b/README.md @@ -391,7 +391,7 @@ Alamofire.request("https://gameofthrones.org/mostFavoriteCharacter").responseStr ## What about images -If you want to load image into `UIImageView` or `NSImageView`, then we also have a nice gift for you. It's called [Imaginary](https://github.com/hyperoslo/Imaginary) and uses `Cache` under the hood to make you life easier when it comes to working with remote images. +If you want to load image into `UIImageView` or `NSImageView`, then we also have a nice gift for you. It's called [Imaginary](https://github.com/hyperoslo/Imaginary) and uses `Cache` under the hood to make your life easier when it comes to working with remote images. ## Installation From 08de6c481cabc4ca06f4cbbbbcb4cfad15dcede3 Mon Sep 17 00:00:00 2001 From: Maxb Date: Fri, 27 May 2022 17:10:09 +0800 Subject: [PATCH 05/31] remove older files not recent --- Source/Shared/Storage/DiskStorage.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Shared/Storage/DiskStorage.swift b/Source/Shared/Storage/DiskStorage.swift index ca4db9a1..0eca4b88 100644 --- a/Source/Shared/Storage/DiskStorage.swift +++ b/Source/Shared/Storage/DiskStorage.swift @@ -217,7 +217,7 @@ extension DiskStorage { let sortedFiles = objects.sorted { if let time1 = $0.resourceValues.contentModificationDate?.timeIntervalSinceReferenceDate, let time2 = $1.resourceValues.contentModificationDate?.timeIntervalSinceReferenceDate { - return time1 > time2 + return time1 < time2 } else { return false } From 33a693c45e8ad1db4e7be59c6181f076195fc34c Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Sun, 14 Aug 2022 13:48:44 -0400 Subject: [PATCH 06/31] Add objectExists to replace existsObject --- Source/Shared/Storage/AsyncStorage.swift | 11 +++++++++++ Source/Shared/Storage/StorageAware.swift | 16 ++++++++++++++++ Tests/iOS/Tests/Storage/AsyncStorageTests.swift | 2 +- Tests/iOS/Tests/Storage/SyncStorageTests.swift | 4 ++-- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Source/Shared/Storage/AsyncStorage.swift b/Source/Shared/Storage/AsyncStorage.swift index 032ea08a..4f1c1b04 100644 --- a/Source/Shared/Storage/AsyncStorage.swift +++ b/Source/Shared/Storage/AsyncStorage.swift @@ -106,6 +106,7 @@ extension AsyncStorage { }) } + @available(*, deprecated, renamed: "objectExists(forKey:completion:)") public func existsObject( forKey key: Key, completion: @escaping (Result) -> Void) { @@ -115,6 +116,16 @@ extension AsyncStorage { })) }) } + + public func objectExists( + forKey key: Key, + completion: @escaping (Result) -> Void) { + object(forKey: key, completion: { (result: Result) in + completion(result.map({ _ in + return true + })) + }) + } } public extension AsyncStorage { diff --git a/Source/Shared/Storage/StorageAware.swift b/Source/Shared/Storage/StorageAware.swift index cbbb8ce2..2b589416 100644 --- a/Source/Shared/Storage/StorageAware.swift +++ b/Source/Shared/Storage/StorageAware.swift @@ -47,8 +47,15 @@ public protocol StorageAware { Check if an object exist by the given key. - Parameter key: Unique key to identify the object. */ + @available(*, deprecated, renamed: "objectExists(forKey:)") func existsObject(forKey key: Key) throws -> Bool + /** + Check if an object exist by the given key. + - Parameter key: Unique key to identify the object. + */ + func objectExists(forKey key: Key) -> Bool + /** Removes all objects from the cache storage. */ @@ -80,6 +87,15 @@ public extension StorageAware { } } + func objectExists(forKey key: Key) -> Bool { + do { + let _: Value = try object(forKey: key) + return true + } catch { + return false + } + } + func isExpiredObject(forKey key: Key) throws -> Bool { do { let entry = try self.entry(forKey: key) diff --git a/Tests/iOS/Tests/Storage/AsyncStorageTests.swift b/Tests/iOS/Tests/Storage/AsyncStorageTests.swift index 63158dc3..1251d152 100644 --- a/Tests/iOS/Tests/Storage/AsyncStorageTests.swift +++ b/Tests/iOS/Tests/Storage/AsyncStorageTests.swift @@ -50,7 +50,7 @@ final class AsyncStorageTests: XCTestCase { } then("all are removed") { - intStorage.existsObject(forKey: "key-99", completion: { result in + intStorage.objectExists(forKey: "key-99", completion: { result in switch result { case .success: XCTFail() diff --git a/Tests/iOS/Tests/Storage/SyncStorageTests.swift b/Tests/iOS/Tests/Storage/SyncStorageTests.swift index 4c055b33..8d31f820 100644 --- a/Tests/iOS/Tests/Storage/SyncStorageTests.swift +++ b/Tests/iOS/Tests/Storage/SyncStorageTests.swift @@ -40,8 +40,8 @@ final class SyncStorageTests: XCTestCase { try intStorage.removeAll() } - try then("all are removed") { - XCTAssertFalse(try intStorage.existsObject(forKey: "key-99")) + then("all are removed") { + XCTAssertFalse(intStorage.objectExists(forKey: "key-99")) } } } From de764f82582d5bf55a86f4ee798bdb856403f492 Mon Sep 17 00:00:00 2001 From: pareshios Date: Tue, 2 May 2023 16:54:49 +0530 Subject: [PATCH 07/31] feat: Added support to remove only in memory cache --- Source/Shared/Storage/DiskStorage.swift | 2 ++ Source/Shared/Storage/HybridStorage.swift | 5 +++++ Source/Shared/Storage/MemoryStorage.swift | 5 +++++ Source/Shared/Storage/Storage.swift | 4 ++++ Source/Shared/Storage/StorageAware.swift | 5 +++++ Source/Shared/Storage/StorageObservationRegistry.swift | 3 ++- Source/Shared/Storage/SyncStorage.swift | 7 +++++++ 7 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Source/Shared/Storage/DiskStorage.swift b/Source/Shared/Storage/DiskStorage.swift index ca4db9a1..b0bf9e37 100644 --- a/Source/Shared/Storage/DiskStorage.swift +++ b/Source/Shared/Storage/DiskStorage.swift @@ -145,6 +145,8 @@ extension DiskStorage: StorageAware { // Remove objects if storage size exceeds max size try removeResourceObjects(resourceObjects, totalSize: totalSize) } + + public func removeInMemoryObject(forKey key: Key) throws { } } extension DiskStorage { diff --git a/Source/Shared/Storage/HybridStorage.swift b/Source/Shared/Storage/HybridStorage.swift index 385980fe..98448035 100644 --- a/Source/Shared/Storage/HybridStorage.swift +++ b/Source/Shared/Storage/HybridStorage.swift @@ -51,6 +51,11 @@ extension HybridStorage: StorageAware { notifyStorageObservers(about: .remove(key: key)) } + + public func removeInMemoryObject(forKey key: Key) throws { + memoryStorage.removeObject(forKey: key) + notifyStorageObservers(about: .removeInMemory(key: key)) + } public func setObject(_ object: Value, forKey key: Key, expiry: Expiry? = nil) throws { var keyChange: KeyChange? diff --git a/Source/Shared/Storage/MemoryStorage.swift b/Source/Shared/Storage/MemoryStorage.swift index 1adc46ff..567bf317 100644 --- a/Source/Shared/Storage/MemoryStorage.swift +++ b/Source/Shared/Storage/MemoryStorage.swift @@ -67,6 +67,11 @@ extension MemoryStorage { cache.removeObject(forKey: WrappedKey(key)) keys.remove(key) } + + public func removeInMemoryObject(forKey key: Key) throws { + cache.removeObject(forKey: WrappedKey(key)) + keys.remove(key) + } public func entry(forKey key: Key) throws -> Entry { guard let capsule = cache.object(forKey: WrappedKey(key)) else { diff --git a/Source/Shared/Storage/Storage.swift b/Source/Shared/Storage/Storage.swift index e2d7c69c..12b567f1 100644 --- a/Source/Shared/Storage/Storage.swift +++ b/Source/Shared/Storage/Storage.swift @@ -43,6 +43,10 @@ public final class Storage { } extension Storage: StorageAware { + public func removeInMemoryObject(forKey key: Key) throws { + try self.syncStorage.removeInMemoryObject(forKey: key) + } + public var allKeys: [Key] { self.syncStorage.allKeys } diff --git a/Source/Shared/Storage/StorageAware.swift b/Source/Shared/Storage/StorageAware.swift index 2b589416..6ab7b3f5 100644 --- a/Source/Shared/Storage/StorageAware.swift +++ b/Source/Shared/Storage/StorageAware.swift @@ -71,6 +71,11 @@ public protocol StorageAware { - Parameter key: Unique key to identify the object. */ func isExpiredObject(forKey key: Key) throws -> Bool + /** + Removes the object by the given key from cache in memory only. + - Parameter key: Unique key to identify the object. + */ + func removeInMemoryObject(forKey key: Key) throws } public extension StorageAware { diff --git a/Source/Shared/Storage/StorageObservationRegistry.swift b/Source/Shared/Storage/StorageObservationRegistry.swift index abd4927a..788631e6 100644 --- a/Source/Shared/Storage/StorageObservationRegistry.swift +++ b/Source/Shared/Storage/StorageObservationRegistry.swift @@ -28,11 +28,12 @@ public enum StorageChange: Equatable { case remove(key: Key) case removeAll case removeExpired + case removeInMemory(key: Key) } public func == (lhs: StorageChange, rhs: StorageChange) -> Bool { switch (lhs, rhs) { - case (.add(let key1), .add(let key2)), (.remove(let key1), .remove(let key2)): + case (.add(let key1), .add(let key2)), (.remove(let key1), .remove(let key2)), (.removeInMemory(let key1), .removeInMemory(let key2)): return key1 == key2 case (.removeAll, .removeAll), (.removeExpired, .removeExpired): return true diff --git a/Source/Shared/Storage/SyncStorage.swift b/Source/Shared/Storage/SyncStorage.swift index 51d15f0e..b7bab940 100644 --- a/Source/Shared/Storage/SyncStorage.swift +++ b/Source/Shared/Storage/SyncStorage.swift @@ -61,6 +61,13 @@ extension SyncStorage: StorageAware { try innerStorage.removeExpiredObjects() } } + + public func removeInMemoryObject(forKey key: Key) throws { + try serialQueue.sync { + try self.innerStorage.removeInMemoryObject(forKey: key) + } + } + } public extension SyncStorage { From ca92308ff98c60bccf7e9422896bf40d320f5799 Mon Sep 17 00:00:00 2001 From: Mike Hill Date: Thu, 4 Jan 2024 10:27:09 -0500 Subject: [PATCH 08/31] Update TransformerFactory.swift to add visionOS (#1) --- Source/Shared/Library/TransformerFactory.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Shared/Library/TransformerFactory.swift b/Source/Shared/Library/TransformerFactory.swift index 00e4fe9a..8ee64ab9 100644 --- a/Source/Shared/Library/TransformerFactory.swift +++ b/Source/Shared/Library/TransformerFactory.swift @@ -9,7 +9,7 @@ public class TransformerFactory { return Transformer(toData: toData, fromData: fromData) } - #if os(iOS) || os(tvOS) || os(macOS) + #if os(iOS) || os(tvOS) || os(macOS) || os(visionOS) public static func forImage() -> Transformer { let toData: (Image) throws -> Data = { image in return try image.cache_toData().unwrapOrThrow(error: StorageError.transformerFail) From 8b895e5ee3522a3d2783108e3152a14548ea3035 Mon Sep 17 00:00:00 2001 From: Mike Hill Date: Thu, 4 Jan 2024 10:32:57 -0500 Subject: [PATCH 09/31] Update Types.swift to add visionOS --- Source/Shared/Library/Types.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Shared/Library/Types.swift b/Source/Shared/Library/Types.swift index 81e7a301..e8408db4 100644 --- a/Source/Shared/Library/Types.swift +++ b/Source/Shared/Library/Types.swift @@ -1,4 +1,4 @@ -#if os(iOS) || os(tvOS) +#if os(iOS) || os(tvOS) || os(visionOS) import UIKit public typealias Image = UIImage #elseif os(watchOS) From 08608e367aa74a48e8f27ff44c6ba75a9f0f23aa Mon Sep 17 00:00:00 2001 From: Keita Watanabe Date: Wed, 21 Feb 2024 11:06:47 +0900 Subject: [PATCH 10/31] add PrivacyInfo.xcprivacy --- Source/PrivacyInfo.xcprivacy | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Source/PrivacyInfo.xcprivacy diff --git a/Source/PrivacyInfo.xcprivacy b/Source/PrivacyInfo.xcprivacy new file mode 100644 index 00000000..0c67376e --- /dev/null +++ b/Source/PrivacyInfo.xcprivacy @@ -0,0 +1,5 @@ + + + + + From bf2fd30e560d69736fceb27b2da7ff728ba7e320 Mon Sep 17 00:00:00 2001 From: Keita Watanabe Date: Wed, 21 Feb 2024 11:16:40 +0900 Subject: [PATCH 11/31] add resources --- Package.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index c167e646..30ce2b8d 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.1 +// swift-tools-version:5.5 import PackageDescription @@ -13,7 +13,8 @@ let package = Package( targets: [ .target( name: "Cache", - path: "Source" + path: "Source", + resources: [.copy("PrivacyInfo.xcprivacy")] ), .testTarget( name: "CacheTests", From e32a01da7a847266a0f7268ed467cd4b0fdf794e Mon Sep 17 00:00:00 2001 From: Keita Watanabe Date: Wed, 21 Feb 2024 11:39:25 +0900 Subject: [PATCH 12/31] add NSPrivacyAccessedAPICategoryFileTimestamp for modificationDate and contentModificationDateKey --- Source/PrivacyInfo.xcprivacy | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/PrivacyInfo.xcprivacy b/Source/PrivacyInfo.xcprivacy index 0c67376e..1d40f906 100644 --- a/Source/PrivacyInfo.xcprivacy +++ b/Source/PrivacyInfo.xcprivacy @@ -1,5 +1,17 @@ - + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPITypeReasons + + C617.1 + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + + + From 049ef1af424ecb999c4ba8f8c172714fead2ce74 Mon Sep 17 00:00:00 2001 From: Keita Watanabe Date: Wed, 21 Feb 2024 11:44:15 +0900 Subject: [PATCH 13/31] add NSPrivacyCollectedDataTypes --- Source/PrivacyInfo.xcprivacy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/PrivacyInfo.xcprivacy b/Source/PrivacyInfo.xcprivacy index 1d40f906..934f6eda 100644 --- a/Source/PrivacyInfo.xcprivacy +++ b/Source/PrivacyInfo.xcprivacy @@ -2,6 +2,8 @@ + NSPrivacyCollectedDataTypes + NSPrivacyAccessedAPITypes From 1014bad6967f8afcc2675e700e011894d8e93391 Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 22 Mar 2024 10:17:33 -0700 Subject: [PATCH 14/31] Include privacy manifest in podspec --- Cache.podspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cache.podspec b/Cache.podspec index c74a7c91..927952ad 100644 --- a/Cache.podspec +++ b/Cache.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Cache" s.summary = "Nothing but cache." - s.version = "7.0.0" + s.version = "7.0.1" s.homepage = "https://github.com/hyperoslo/Cache" s.license = 'MIT' s.author = { "Hyper Interaktiv AS" => "ios@hyper.no" } @@ -16,6 +16,7 @@ Pod::Spec.new do |s| s.ios.source_files = 'Source/{iOS,Shared}/**/*' s.osx.source_files = 'Source/{Mac,Shared}/**/*' s.tvos.source_files = 'Source/{iOS,Shared}/**/*' + s.resources = 'Source/PrivacyInfo.xcprivacy' s.frameworks = 'Foundation' s.swift_version = '5.0' From ec9f3af90d63a8fb32cb2abe91d4c53f46d8dd93 Mon Sep 17 00:00:00 2001 From: Elvis <3lvis@users.noreply.github.com> Date: Tue, 26 Mar 2024 06:25:29 +0100 Subject: [PATCH 15/31] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 45afb49e..ee260ebf 100644 --- a/README.md +++ b/README.md @@ -398,10 +398,11 @@ If you want to load image into `UIImageView` or `NSImageView`, then we also have ### Cocoapods **Cache** is available through [CocoaPods](http://cocoapods.org). To install -it, simply add the following line to your Podfile: +it or update it, use the following line to your Podfile: ```ruby -pod 'Cache' +pod 'Cache', :git => 'https://github.com/hyperoslo/Cache.git' + ``` ### Carthage From 81fc4e5310db0bae64ea92f9f84551895b2a0e6f Mon Sep 17 00:00:00 2001 From: Elvis Date: Tue, 26 Mar 2024 10:30:54 +0100 Subject: [PATCH 16/31] Revert "Merge pull request #288 from escfrya/support-watchos" This reverts commit 472e8f59f9f4ca10a8b9b25342dc27db28d7caef, reversing changes made to ec9f3af90d63a8fb32cb2abe91d4c53f46d8dd93. --- Cache.podspec | 2 - Cache.xcodeproj/project.pbxproj | 208 ------------------ Source/Shared/Configuration/DiskConfig.swift | 2 +- Source/Shared/Library/ImageWrapper.swift | 2 +- .../Shared/Library/TransformerFactory.swift | 2 +- Source/Shared/Library/Types.swift | 2 +- Source/Shared/Storage/DiskStorage.swift | 2 +- Source/Shared/Storage/Storage+Transform.swift | 2 +- SupportFiles/watchOS/Info.plist | 22 -- 9 files changed, 6 insertions(+), 238 deletions(-) delete mode 100644 SupportFiles/watchOS/Info.plist diff --git a/Cache.podspec b/Cache.podspec index 5a6f4b02..927952ad 100644 --- a/Cache.podspec +++ b/Cache.podspec @@ -11,13 +11,11 @@ Pod::Spec.new do |s| s.ios.deployment_target = '11.0' s.osx.deployment_target = '10.12' s.tvos.deployment_target = '11.0' - s.watchos.deployment_target = '5.0' s.requires_arc = true s.ios.source_files = 'Source/{iOS,Shared}/**/*' s.osx.source_files = 'Source/{Mac,Shared}/**/*' s.tvos.source_files = 'Source/{iOS,Shared}/**/*' - s.watchos.source_files = 'Source/{iOS,Shared}/**/*' s.resources = 'Source/PrivacyInfo.xcprivacy' s.frameworks = 'Foundation' diff --git a/Cache.xcodeproj/project.pbxproj b/Cache.xcodeproj/project.pbxproj index 16694beb..4b3d8b5b 100644 --- a/Cache.xcodeproj/project.pbxproj +++ b/Cache.xcodeproj/project.pbxproj @@ -153,40 +153,6 @@ D5A9D1C321144B65005DBD3F /* StorageObservationRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9D1C221144B65005DBD3F /* StorageObservationRegistry.swift */; }; D5A9D1C421144B65005DBD3F /* StorageObservationRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9D1C221144B65005DBD3F /* StorageObservationRegistry.swift */; }; D5A9D1C521144B65005DBD3F /* StorageObservationRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9D1C221144B65005DBD3F /* StorageObservationRegistry.swift */; }; - F812FB77264D57BC00D179F5 /* MemoryConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF984E1F694FFA00CE8F68 /* MemoryConfig.swift */; }; - F812FB78264D57BC00D179F5 /* DiskConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF984D1F694FFA00CE8F68 /* DiskConfig.swift */; }; - F812FB79264D57BC00D179F5 /* Date+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98501F694FFA00CE8F68 /* Date+Extensions.swift */; }; - F812FB7A264D57BC00D179F5 /* Hasher+constantAccrossExecutions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E791649250E2AA500A71666 /* Hasher+constantAccrossExecutions.swift */; }; - F812FB7B264D57BC00D179F5 /* JSONDecoder+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28897041F8B79B300C61DEE /* JSONDecoder+Extensions.swift */; }; - F812FB7C264D57BC00D179F5 /* URL+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2292AB7A252A14520031F3B9 /* URL+Extensions.swift */; }; - F812FB7D264D57BC00D179F5 /* FileManager+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2292AB84252A14F50031F3B9 /* FileManager+Extensions.swift */; }; - F812FB7E264D57C300D179F5 /* TransformerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27014A420D129EB003B45C7 /* TransformerFactory.swift */; }; - F812FB7F264D57C300D179F5 /* Optional+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270148B20D113EA003B45C7 /* Optional+Extension.swift */; }; - F812FB80264D57C300D179F5 /* JSONDictionaryWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D4CC1F1FA3411300E4A2D5 /* JSONDictionaryWrapper.swift */; }; - F812FB81264D57C300D179F5 /* ExpirationMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98551F694FFA00CE8F68 /* ExpirationMode.swift */; }; - F812FB82264D57C300D179F5 /* ImageWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98571F694FFA00CE8F68 /* ImageWrapper.swift */; }; - F812FB83264D57C300D179F5 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98861F695B8F00CE8F68 /* Types.swift */; }; - F812FB84264D57C300D179F5 /* StorageError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98591F694FFA00CE8F68 /* StorageError.swift */; }; - F812FB85264D57C300D179F5 /* JSONArrayWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D4CC231FA3426B00E4A2D5 /* JSONArrayWrapper.swift */; }; - F812FB86264D57C300D179F5 /* TypeWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270148F20D1251E003B45C7 /* TypeWrapper.swift */; }; - F812FB87264D57C300D179F5 /* ObservationToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9D1B621134547005DBD3F /* ObservationToken.swift */; }; - F812FB88264D57C300D179F5 /* Entry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D221E5BF20D00DCC00BC940E /* Entry.swift */; }; - F812FB89264D57C300D179F5 /* MemoryCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270149320D125AC003B45C7 /* MemoryCapsule.swift */; }; - F812FB8A264D57C300D179F5 /* DataSerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98531F694FFA00CE8F68 /* DataSerializer.swift */; }; - F812FB8B264D57C300D179F5 /* Expiry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98561F694FFA00CE8F68 /* Expiry.swift */; }; - F812FB8C264D57C300D179F5 /* MD5.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D4CC151FA3145000E4A2D5 /* MD5.swift */; }; - F812FB8D264D57C300D179F5 /* Transformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270146F20D1018A003B45C7 /* Transformer.swift */; }; - F812FB8E264D57C800D179F5 /* Storage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270147F20D10982003B45C7 /* Storage.swift */; }; - F812FB8F264D57C800D179F5 /* StorageObservationRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9D1C221144B65005DBD3F /* StorageObservationRegistry.swift */; }; - F812FB90264D57C800D179F5 /* HybridStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270147720D1046A003B45C7 /* HybridStorage.swift */; }; - F812FB91264D57C800D179F5 /* SyncStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270147B20D107DA003B45C7 /* SyncStorage.swift */; }; - F812FB92264D57C800D179F5 /* MemoryStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D221E5BB20D00D9300BC940E /* MemoryStorage.swift */; }; - F812FB93264D57C800D179F5 /* KeyObservationRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D51146522118337500197DCE /* KeyObservationRegistry.swift */; }; - F812FB94264D57C800D179F5 /* AsyncStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270148320D10E76003B45C7 /* AsyncStorage.swift */; }; - F812FB95264D57C800D179F5 /* Storage+Transform.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270148720D11040003B45C7 /* Storage+Transform.swift */; }; - F812FB96264D57C800D179F5 /* DiskStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D221E5C320D00DDB00BC940E /* DiskStorage.swift */; }; - F812FB97264D57C800D179F5 /* StorageAware.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270147320D101F3003B45C7 /* StorageAware.swift */; }; - F812FB98264D57CC00D179F5 /* UIImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A138C01EB29BFA00881A20 /* UIImage+Extensions.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -283,9 +249,6 @@ D5A9D1C221144B65005DBD3F /* StorageObservationRegistry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageObservationRegistry.swift; sourceTree = ""; }; D5DC59E01C20593E003BD79B /* Cache.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cache.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EBAACA991FBC369300FA206E /* SimpleStorage.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = SimpleStorage.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - F812FB6F264D579E00D179F5 /* Cache_watchOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cache_watchOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - F812FB71264D579E00D179F5 /* Cache_watchOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Cache_watchOS.h; sourceTree = ""; }; - F812FB72264D579E00D179F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -334,13 +297,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - F812FB6C264D579E00D179F5 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -552,7 +508,6 @@ D5643E341C43F2CC00582E17 /* Playgrounds */, D5291C081C28220B00B702C9 /* Source */, D5DC59FA1C205AC9003BD79B /* Tests */, - F812FB70264D579E00D179F5 /* Cache-watchOS */, D5DC59E11C20593E003BD79B /* Products */, ); indentWidth = 4; @@ -568,7 +523,6 @@ D5291D691C283B5400B702C9 /* Cache-Mac-Tests.xctest */, BDEDD3561DBCE5B1007416A6 /* Cache.framework */, BDEDD3781DBCEB8A007416A6 /* Cache-tvOS-Tests.xctest */, - F812FB6F264D579E00D179F5 /* Cache_watchOS.framework */, ); name = Products; sourceTree = ""; @@ -583,15 +537,6 @@ path = Tests; sourceTree = ""; }; - F812FB70264D579E00D179F5 /* Cache-watchOS */ = { - isa = PBXGroup; - children = ( - F812FB71264D579E00D179F5 /* Cache_watchOS.h */, - F812FB72264D579E00D179F5 /* Info.plist */, - ); - path = "Cache-watchOS"; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -616,13 +561,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - F812FB6A264D579E00D179F5 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ @@ -734,24 +672,6 @@ productReference = D5DC59E01C20593E003BD79B /* Cache.framework */; productType = "com.apple.product-type.framework"; }; - F812FB6E264D579E00D179F5 /* Cache-watchOS */ = { - isa = PBXNativeTarget; - buildConfigurationList = F812FB76264D579E00D179F5 /* Build configuration list for PBXNativeTarget "Cache-watchOS" */; - buildPhases = ( - F812FB6A264D579E00D179F5 /* Headers */, - F812FB6B264D579E00D179F5 /* Sources */, - F812FB6C264D579E00D179F5 /* Frameworks */, - F812FB6D264D579E00D179F5 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "Cache-watchOS"; - productName = "Cache-watchOS"; - productReference = F812FB6F264D579E00D179F5 /* Cache_watchOS.framework */; - productType = "com.apple.product-type.framework"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -785,10 +705,6 @@ CreatedOnToolsVersion = 7.2; LastSwiftMigration = 0800; }; - F812FB6E264D579E00D179F5 = { - CreatedOnToolsVersion = 12.5; - ProvisioningStyle = Manual; - }; }; }; buildConfigurationList = D5DC59DA1C20593E003BD79B /* Build configuration list for PBXProject "Cache" */; @@ -810,7 +726,6 @@ D5291D681C283B5400B702C9 /* Cache-Mac-Tests */, BDEDD3551DBCE5B1007416A6 /* Cache-tvOS */, BDEDD3771DBCEB8A007416A6 /* Cache-tvOS-Tests */, - F812FB6E264D579E00D179F5 /* Cache-watchOS */, ); }; /* End PBXProject section */ @@ -858,13 +773,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - F812FB6D264D579E00D179F5 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -1053,47 +961,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - F812FB6B264D579E00D179F5 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - F812FB95264D57C800D179F5 /* Storage+Transform.swift in Sources */, - F812FB81264D57C300D179F5 /* ExpirationMode.swift in Sources */, - F812FB82264D57C300D179F5 /* ImageWrapper.swift in Sources */, - F812FB78264D57BC00D179F5 /* DiskConfig.swift in Sources */, - F812FB8A264D57C300D179F5 /* DataSerializer.swift in Sources */, - F812FB8D264D57C300D179F5 /* Transformer.swift in Sources */, - F812FB8E264D57C800D179F5 /* Storage.swift in Sources */, - F812FB7D264D57BC00D179F5 /* FileManager+Extensions.swift in Sources */, - F812FB8B264D57C300D179F5 /* Expiry.swift in Sources */, - F812FB92264D57C800D179F5 /* MemoryStorage.swift in Sources */, - F812FB7C264D57BC00D179F5 /* URL+Extensions.swift in Sources */, - F812FB80264D57C300D179F5 /* JSONDictionaryWrapper.swift in Sources */, - F812FB96264D57C800D179F5 /* DiskStorage.swift in Sources */, - F812FB88264D57C300D179F5 /* Entry.swift in Sources */, - F812FB89264D57C300D179F5 /* MemoryCapsule.swift in Sources */, - F812FB8C264D57C300D179F5 /* MD5.swift in Sources */, - F812FB7B264D57BC00D179F5 /* JSONDecoder+Extensions.swift in Sources */, - F812FB91264D57C800D179F5 /* SyncStorage.swift in Sources */, - F812FB87264D57C300D179F5 /* ObservationToken.swift in Sources */, - F812FB97264D57C800D179F5 /* StorageAware.swift in Sources */, - F812FB85264D57C300D179F5 /* JSONArrayWrapper.swift in Sources */, - F812FB7F264D57C300D179F5 /* Optional+Extension.swift in Sources */, - F812FB8F264D57C800D179F5 /* StorageObservationRegistry.swift in Sources */, - F812FB83264D57C300D179F5 /* Types.swift in Sources */, - F812FB90264D57C800D179F5 /* HybridStorage.swift in Sources */, - F812FB77264D57BC00D179F5 /* MemoryConfig.swift in Sources */, - F812FB93264D57C800D179F5 /* KeyObservationRegistry.swift in Sources */, - F812FB84264D57C300D179F5 /* StorageError.swift in Sources */, - F812FB7A264D57BC00D179F5 /* Hasher+constantAccrossExecutions.swift in Sources */, - F812FB94264D57C800D179F5 /* AsyncStorage.swift in Sources */, - F812FB7E264D57C300D179F5 /* TransformerFactory.swift in Sources */, - F812FB98264D57CC00D179F5 /* UIImage+Extensions.swift in Sources */, - F812FB79264D57BC00D179F5 /* Date+Extensions.swift in Sources */, - F812FB86264D57C300D179F5 /* TypeWrapper.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -1463,72 +1330,6 @@ }; name = Release; }; - F812FB74264D579E00D179F5 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - APPLICATION_EXTENSION_API_ONLY = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_STYLE = Manual; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = "$(SRCROOT)/SupportFiles/watchOS/Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-watchOS"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SDKROOT = watchos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 5.0; - }; - name = Debug; - }; - F812FB75264D579E00D179F5 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - APPLICATION_EXTENSION_API_ONLY = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_STYLE = Manual; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = "$(SRCROOT)/SupportFiles/watchOS/Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-watchOS"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SDKROOT = watchos; - SKIP_INSTALL = YES; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 5.0; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -1595,15 +1396,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - F812FB76264D579E00D179F5 /* Build configuration list for PBXNativeTarget "Cache-watchOS" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - F812FB74264D579E00D179F5 /* Debug */, - F812FB75264D579E00D179F5 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ }; rootObject = D5DC59D71C20593E003BD79B /* Project object */; diff --git a/Source/Shared/Configuration/DiskConfig.swift b/Source/Shared/Configuration/DiskConfig.swift index e57212a3..3d0a01c5 100644 --- a/Source/Shared/Configuration/DiskConfig.swift +++ b/Source/Shared/Configuration/DiskConfig.swift @@ -10,7 +10,7 @@ public struct DiskConfig { public let maxSize: UInt /// A folder to store the disk cache contents. Defaults to a prefixed directory in Caches if nil public let directory: URL? - #if os(iOS) || os(tvOS) || os(watchOS) + #if os(iOS) || os(tvOS) /// Data protection is used to store files in an encrypted format on disk and to decrypt them on demand. /// Support only on iOS and tvOS. public let protectionType: FileProtectionType? diff --git a/Source/Shared/Library/ImageWrapper.swift b/Source/Shared/Library/ImageWrapper.swift index 5bc0cdde..cc9fd7d7 100644 --- a/Source/Shared/Library/ImageWrapper.swift +++ b/Source/Shared/Library/ImageWrapper.swift @@ -1,6 +1,6 @@ import Foundation -#if os(iOS) || os(tvOS) || os(macOS) || os(watchOS) +#if os(iOS) || os(tvOS) || os(macOS) public struct ImageWrapper: Codable { public let image: Image diff --git a/Source/Shared/Library/TransformerFactory.swift b/Source/Shared/Library/TransformerFactory.swift index 05fd6b4b..8ee64ab9 100644 --- a/Source/Shared/Library/TransformerFactory.swift +++ b/Source/Shared/Library/TransformerFactory.swift @@ -9,7 +9,7 @@ public class TransformerFactory { return Transformer(toData: toData, fromData: fromData) } - #if os(iOS) || os(tvOS) || os(macOS) || os(watchOS) || os(visionOS) + #if os(iOS) || os(tvOS) || os(macOS) || os(visionOS) public static func forImage() -> Transformer { let toData: (Image) throws -> Data = { image in return try image.cache_toData().unwrapOrThrow(error: StorageError.transformerFail) diff --git a/Source/Shared/Library/Types.swift b/Source/Shared/Library/Types.swift index 52c03b22..e8408db4 100644 --- a/Source/Shared/Library/Types.swift +++ b/Source/Shared/Library/Types.swift @@ -1,4 +1,4 @@ -#if os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) +#if os(iOS) || os(tvOS) || os(visionOS) import UIKit public typealias Image = UIImage #elseif os(watchOS) diff --git a/Source/Shared/Storage/DiskStorage.swift b/Source/Shared/Storage/DiskStorage.swift index d21a31f2..b0bf9e37 100644 --- a/Source/Shared/Storage/DiskStorage.swift +++ b/Source/Shared/Storage/DiskStorage.swift @@ -40,7 +40,7 @@ final public class DiskStorage { try createDirectory() // protection - #if os(iOS) || os(tvOS) || os(watchOS) + #if os(iOS) || os(tvOS) if let protectionType = config.protectionType { try setDirectoryAttributes([ FileAttributeKey.protectionKey: protectionType diff --git a/Source/Shared/Storage/Storage+Transform.swift b/Source/Shared/Storage/Storage+Transform.swift index af1bc366..494e6afb 100644 --- a/Source/Shared/Storage/Storage+Transform.swift +++ b/Source/Shared/Storage/Storage+Transform.swift @@ -7,7 +7,7 @@ public extension Storage { } - #if os(iOS) || os(tvOS) || os(macOS) || os(watchOS) + #if os(iOS) || os(tvOS) || os(macOS) func transformImage() -> Storage { let storage = transform(transformer: TransformerFactory.forImage()) return storage diff --git a/SupportFiles/watchOS/Info.plist b/SupportFiles/watchOS/Info.plist deleted file mode 100644 index 37f13eb0..00000000 --- a/SupportFiles/watchOS/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - - From f377c321d5a5a0f11327ca04896030172fc2fbd1 Mon Sep 17 00:00:00 2001 From: Elvis Date: Tue, 26 Mar 2024 11:10:49 +0100 Subject: [PATCH 17/31] Clean up and add watchOS support --- Cache.podspec | 7 +- Cache.xcodeproj/project.pbxproj | 347 ++++++++++++++++-- .../xcshareddata/xcschemes/Cache-iOS.xcscheme | 2 +- .../xcschemes/Cache-macOS.xcscheme | 2 +- .../xcschemes/Cache-tvOS.xcscheme | 2 +- Source/Shared/Configuration/DiskConfig.swift | 11 - Source/Shared/Library/ImageWrapper.swift | 6 +- .../Shared/Library/TransformerFactory.swift | 6 +- Source/Shared/Library/Types.swift | 3 +- Source/Shared/Storage/DiskStorage.swift | 3 - Source/Shared/Storage/Storage+Transform.swift | 6 +- Tests/Shared/TestHelper.swift | 6 +- Tests/iOS/Helpers/TestHelper+iOS.swift | 2 +- .../iOS/Helpers/UIImage+ExtensionsTests.swift | 2 +- 14 files changed, 347 insertions(+), 58 deletions(-) diff --git a/Cache.podspec b/Cache.podspec index 927952ad..29f1b3c1 100644 --- a/Cache.podspec +++ b/Cache.podspec @@ -8,9 +8,10 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/hyperoslo/Cache.git", :tag => s.version.to_s } s.social_media_url = 'https://twitter.com/hyperoslo' - s.ios.deployment_target = '11.0' - s.osx.deployment_target = '10.12' - s.tvos.deployment_target = '11.0' + s.ios.deployment_target = '12.0' + s.osx.deployment_target = '10.14' + s.tvos.deployment_target = '12.0' + s.watchos.deployment_target = '6.0' s.requires_arc = true s.ios.source_files = 'Source/{iOS,Shared}/**/*' diff --git a/Cache.xcodeproj/project.pbxproj b/Cache.xcodeproj/project.pbxproj index 4b3d8b5b..ac78aacf 100644 --- a/Cache.xcodeproj/project.pbxproj +++ b/Cache.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -17,6 +17,40 @@ 2292AB85252A14F50031F3B9 /* FileManager+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2292AB84252A14F50031F3B9 /* FileManager+Extensions.swift */; }; 2292AB86252A14F50031F3B9 /* FileManager+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2292AB84252A14F50031F3B9 /* FileManager+Extensions.swift */; }; 2292AB87252A14F50031F3B9 /* FileManager+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2292AB84252A14F50031F3B9 /* FileManager+Extensions.swift */; }; + 285DC4822BB2D1440036F206 /* DiskConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF984D1F694FFA00CE8F68 /* DiskConfig.swift */; }; + 285DC4832BB2D1440036F206 /* MemoryConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF984E1F694FFA00CE8F68 /* MemoryConfig.swift */; }; + 285DC4842BB2D1440036F206 /* Hasher+constantAccrossExecutions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E791649250E2AA500A71666 /* Hasher+constantAccrossExecutions.swift */; }; + 285DC4852BB2D1440036F206 /* JSONDecoder+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28897041F8B79B300C61DEE /* JSONDecoder+Extensions.swift */; }; + 285DC4862BB2D1440036F206 /* Date+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98501F694FFA00CE8F68 /* Date+Extensions.swift */; }; + 285DC4872BB2D1440036F206 /* URL+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2292AB7A252A14520031F3B9 /* URL+Extensions.swift */; }; + 285DC4882BB2D1440036F206 /* FileManager+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2292AB84252A14F50031F3B9 /* FileManager+Extensions.swift */; }; + 285DC4892BB2D1440036F206 /* DataSerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98531F694FFA00CE8F68 /* DataSerializer.swift */; }; + 285DC48A2BB2D1440036F206 /* ExpirationMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98551F694FFA00CE8F68 /* ExpirationMode.swift */; }; + 285DC48B2BB2D1440036F206 /* Expiry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98561F694FFA00CE8F68 /* Expiry.swift */; }; + 285DC48C2BB2D1440036F206 /* ImageWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98571F694FFA00CE8F68 /* ImageWrapper.swift */; }; + 285DC48D2BB2D1440036F206 /* StorageError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98591F694FFA00CE8F68 /* StorageError.swift */; }; + 285DC48E2BB2D1440036F206 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98861F695B8F00CE8F68 /* Types.swift */; }; + 285DC48F2BB2D1440036F206 /* MD5.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D4CC151FA3145000E4A2D5 /* MD5.swift */; }; + 285DC4902BB2D1440036F206 /* JSONDictionaryWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D4CC1F1FA3411300E4A2D5 /* JSONDictionaryWrapper.swift */; }; + 285DC4912BB2D1440036F206 /* JSONArrayWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D4CC231FA3426B00E4A2D5 /* JSONArrayWrapper.swift */; }; + 285DC4922BB2D1440036F206 /* Entry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D221E5BF20D00DCC00BC940E /* Entry.swift */; }; + 285DC4932BB2D1440036F206 /* Transformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270146F20D1018A003B45C7 /* Transformer.swift */; }; + 285DC4942BB2D1440036F206 /* Optional+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270148B20D113EA003B45C7 /* Optional+Extension.swift */; }; + 285DC4952BB2D1440036F206 /* TypeWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270148F20D1251E003B45C7 /* TypeWrapper.swift */; }; + 285DC4962BB2D1440036F206 /* MemoryCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270149320D125AC003B45C7 /* MemoryCapsule.swift */; }; + 285DC4972BB2D1440036F206 /* TransformerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27014A420D129EB003B45C7 /* TransformerFactory.swift */; }; + 285DC4982BB2D1440036F206 /* ObservationToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9D1B621134547005DBD3F /* ObservationToken.swift */; }; + 285DC4992BB2D1440036F206 /* MemoryStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D221E5BB20D00D9300BC940E /* MemoryStorage.swift */; }; + 285DC49A2BB2D1440036F206 /* DiskStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D221E5C320D00DDB00BC940E /* DiskStorage.swift */; }; + 285DC49B2BB2D1440036F206 /* StorageAware.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270147320D101F3003B45C7 /* StorageAware.swift */; }; + 285DC49C2BB2D1440036F206 /* HybridStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270147720D1046A003B45C7 /* HybridStorage.swift */; }; + 285DC49D2BB2D1440036F206 /* SyncStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270147B20D107DA003B45C7 /* SyncStorage.swift */; }; + 285DC49E2BB2D1440036F206 /* Storage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270147F20D10982003B45C7 /* Storage.swift */; }; + 285DC49F2BB2D1440036F206 /* AsyncStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270148320D10E76003B45C7 /* AsyncStorage.swift */; }; + 285DC4A02BB2D1440036F206 /* Storage+Transform.swift in Sources */ = {isa = PBXBuildFile; fileRef = D270148720D11040003B45C7 /* Storage+Transform.swift */; }; + 285DC4A12BB2D1440036F206 /* StorageObservationRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9D1C221144B65005DBD3F /* StorageObservationRegistry.swift */; }; + 285DC4A22BB2D1440036F206 /* KeyObservationRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D51146522118337500197DCE /* KeyObservationRegistry.swift */; }; + 285DC4A32BB2D2DB0036F206 /* UIImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A138C01EB29BFA00881A20 /* UIImage+Extensions.swift */; }; BDEDD37D1DBCEB8A007416A6 /* Cache.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BDEDD3561DBCE5B1007416A6 /* Cache.framework */; }; D21B667C1F6A723C00125DE1 /* DataSerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98531F694FFA00CE8F68 /* DataSerializer.swift */; }; D21B667E1F6A723C00125DE1 /* ExpirationMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CF98551F694FFA00CE8F68 /* ExpirationMode.swift */; }; @@ -184,6 +218,7 @@ 0E79164D250E2B0400A71666 /* Hasher+constantAccrossExecutions+Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Hasher+constantAccrossExecutions+Tests.swift"; sourceTree = ""; }; 2292AB7A252A14520031F3B9 /* URL+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Extensions.swift"; sourceTree = ""; }; 2292AB84252A14F50031F3B9 /* FileManager+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileManager+Extensions.swift"; sourceTree = ""; }; + 285DC47A2BB2CFCC0036F206 /* Cache.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cache.framework; sourceTree = BUILT_PRODUCTS_DIR; }; BDEDD3561DBCE5B1007416A6 /* Cache.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cache.framework; sourceTree = BUILT_PRODUCTS_DIR; }; BDEDD3781DBCEB8A007416A6 /* Cache-tvOS-Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Cache-tvOS-Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; D221E5BB20D00D9300BC940E /* MemoryStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemoryStorage.swift; sourceTree = ""; }; @@ -252,6 +287,13 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 285DC4772BB2CFCC0036F206 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; BDEDD3521DBCE5B1007416A6 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -523,6 +565,7 @@ D5291D691C283B5400B702C9 /* Cache-Mac-Tests.xctest */, BDEDD3561DBCE5B1007416A6 /* Cache.framework */, BDEDD3781DBCEB8A007416A6 /* Cache-tvOS-Tests.xctest */, + 285DC47A2BB2CFCC0036F206 /* Cache.framework */, ); name = Products; sourceTree = ""; @@ -540,6 +583,13 @@ /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ + 285DC4812BB2D11B0036F206 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; BDEDD3531DBCE5B1007416A6 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -564,6 +614,24 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ + 285DC4792BB2CFCC0036F206 /* Cache-watchOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 285DC47E2BB2CFCC0036F206 /* Build configuration list for PBXNativeTarget "Cache-watchOS" */; + buildPhases = ( + 285DC4812BB2D11B0036F206 /* Headers */, + 285DC4762BB2CFCC0036F206 /* Sources */, + 285DC4772BB2CFCC0036F206 /* Frameworks */, + 285DC4782BB2CFCC0036F206 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Cache-watchOS"; + productName = "Cache-watchOS"; + productReference = 285DC47A2BB2CFCC0036F206 /* Cache.framework */; + productType = "com.apple.product-type.framework"; + }; BDEDD3551DBCE5B1007416A6 /* Cache-tvOS */ = { isa = PBXNativeTarget; buildConfigurationList = BDEDD35D1DBCE5B1007416A6 /* Build configuration list for PBXNativeTarget "Cache-tvOS" */; @@ -678,10 +746,14 @@ D5DC59D71C20593E003BD79B /* Project object */ = { isa = PBXProject; attributes = { + BuildIndependentTargetsInParallel = YES; LastSwiftUpdateCheck = 0800; - LastUpgradeCheck = 1200; + LastUpgradeCheck = 1530; ORGANIZATIONNAME = "Hyper Interaktiv AS"; TargetAttributes = { + 285DC4792BB2CFCC0036F206 = { + CreatedOnToolsVersion = 15.3; + }; BDEDD3551DBCE5B1007416A6 = { CreatedOnToolsVersion = 8.0; ProvisioningStyle = Manual; @@ -726,11 +798,19 @@ D5291D681C283B5400B702C9 /* Cache-Mac-Tests */, BDEDD3551DBCE5B1007416A6 /* Cache-tvOS */, BDEDD3771DBCEB8A007416A6 /* Cache-tvOS-Tests */, + 285DC4792BB2CFCC0036F206 /* Cache-watchOS */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 285DC4782BB2CFCC0036F206 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; BDEDD3541DBCE5B1007416A6 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -776,6 +856,47 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 285DC4762BB2CFCC0036F206 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 285DC4A32BB2D2DB0036F206 /* UIImage+Extensions.swift in Sources */, + 285DC4822BB2D1440036F206 /* DiskConfig.swift in Sources */, + 285DC4832BB2D1440036F206 /* MemoryConfig.swift in Sources */, + 285DC4842BB2D1440036F206 /* Hasher+constantAccrossExecutions.swift in Sources */, + 285DC4852BB2D1440036F206 /* JSONDecoder+Extensions.swift in Sources */, + 285DC4862BB2D1440036F206 /* Date+Extensions.swift in Sources */, + 285DC4872BB2D1440036F206 /* URL+Extensions.swift in Sources */, + 285DC4882BB2D1440036F206 /* FileManager+Extensions.swift in Sources */, + 285DC4892BB2D1440036F206 /* DataSerializer.swift in Sources */, + 285DC48A2BB2D1440036F206 /* ExpirationMode.swift in Sources */, + 285DC48B2BB2D1440036F206 /* Expiry.swift in Sources */, + 285DC48C2BB2D1440036F206 /* ImageWrapper.swift in Sources */, + 285DC48D2BB2D1440036F206 /* StorageError.swift in Sources */, + 285DC48E2BB2D1440036F206 /* Types.swift in Sources */, + 285DC48F2BB2D1440036F206 /* MD5.swift in Sources */, + 285DC4902BB2D1440036F206 /* JSONDictionaryWrapper.swift in Sources */, + 285DC4912BB2D1440036F206 /* JSONArrayWrapper.swift in Sources */, + 285DC4922BB2D1440036F206 /* Entry.swift in Sources */, + 285DC4932BB2D1440036F206 /* Transformer.swift in Sources */, + 285DC4942BB2D1440036F206 /* Optional+Extension.swift in Sources */, + 285DC4952BB2D1440036F206 /* TypeWrapper.swift in Sources */, + 285DC4962BB2D1440036F206 /* MemoryCapsule.swift in Sources */, + 285DC4972BB2D1440036F206 /* TransformerFactory.swift in Sources */, + 285DC4982BB2D1440036F206 /* ObservationToken.swift in Sources */, + 285DC4992BB2D1440036F206 /* MemoryStorage.swift in Sources */, + 285DC49A2BB2D1440036F206 /* DiskStorage.swift in Sources */, + 285DC49B2BB2D1440036F206 /* StorageAware.swift in Sources */, + 285DC49C2BB2D1440036F206 /* HybridStorage.swift in Sources */, + 285DC49D2BB2D1440036F206 /* SyncStorage.swift in Sources */, + 285DC49E2BB2D1440036F206 /* Storage.swift in Sources */, + 285DC49F2BB2D1440036F206 /* AsyncStorage.swift in Sources */, + 285DC4A02BB2D1440036F206 /* Storage+Transform.swift in Sources */, + 285DC4A12BB2D1440036F206 /* StorageObservationRegistry.swift in Sources */, + 285DC4A22BB2D1440036F206 /* KeyObservationRegistry.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; BDEDD3511DBCE5B1007416A6 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -982,6 +1103,100 @@ /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ + 285DC47F2BB2CFCC0036F206 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + BUILD_LIBRARY_FOR_DISTRIBUTION = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = NO; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2024 Hyper Interaktiv AS. All rights reserved."; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-watchOS"; + PRODUCT_NAME = Cache; + SDKROOT = watchos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_INSTALL_OBJC_HEADER = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 6.0; + }; + name = Debug; + }; + 285DC4802BB2CFCC0036F206 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + BUILD_LIBRARY_FOR_DISTRIBUTION = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = NO; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2024 Hyper Interaktiv AS. All rights reserved."; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-watchOS"; + PRODUCT_NAME = Cache; + SDKROOT = watchos; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_INSTALL_OBJC_HEADER = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 6.0; + }; + name = Release; + }; BDEDD35B1DBCE5B1007416A6 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -994,17 +1209,23 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/SupportFiles/tvOS/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-tvOS"; PRODUCT_NAME = Cache; SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 11.0; + TVOS_DEPLOYMENT_TARGET = 12.0; }; name = Debug; }; @@ -1020,16 +1241,22 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/SupportFiles/tvOS/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-tvOS"; PRODUCT_NAME = Cache; SDKROOT = appletvos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 11.0; + TVOS_DEPLOYMENT_TARGET = 12.0; }; name = Release; }; @@ -1043,7 +1270,11 @@ DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/Tests/tvOS/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-tvOS-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; @@ -1064,7 +1295,11 @@ DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/Tests/tvOS/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-tvOS-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; @@ -1079,10 +1314,17 @@ CLANG_ENABLE_MODULES = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/Tests/iOS/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-iOS-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator watchos watchsimulator"; + SUPPORTS_MACCATALYST = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2,4"; }; name = Debug; }; @@ -1092,9 +1334,16 @@ CLANG_ENABLE_MODULES = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/Tests/iOS/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-iOS-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator watchos watchsimulator"; + SUPPORTS_MACCATALYST = YES; + TARGETED_DEVICE_FAMILY = "1,2,4"; }; name = Release; }; @@ -1103,16 +1352,23 @@ buildSettings = { CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; FRAMEWORK_VERSION = A; INFOPLIST_FILE = "$(SRCROOT)/SupportFiles/Mac/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.12; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-Mac"; PRODUCT_NAME = Cache; SDKROOT = macosx; @@ -1125,16 +1381,23 @@ buildSettings = { CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; FRAMEWORK_VERSION = A; INFOPLIST_FILE = "$(SRCROOT)/SupportFiles/Mac/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.12; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-Mac"; PRODUCT_NAME = Cache; SDKROOT = macosx; @@ -1147,9 +1410,14 @@ buildSettings = { CODE_SIGN_IDENTITY = "-"; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/Tests/Mac/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + ); MACOSX_DEPLOYMENT_TARGET = 10.15; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1162,9 +1430,14 @@ buildSettings = { CODE_SIGN_IDENTITY = "-"; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/Tests/Mac/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + ); MACOSX_DEPLOYMENT_TARGET = 10.15; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1221,7 +1494,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -1276,10 +1549,11 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -1291,19 +1565,26 @@ D5DC59F51C20593E003BD79B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + CODE_SIGN_IDENTITY = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/SupportFiles/iOS/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Cache; PRODUCT_NAME = Cache; SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -1312,19 +1593,26 @@ D5DC59F61C20593E003BD79B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + CODE_SIGN_IDENTITY = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/SupportFiles/iOS/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Cache; PRODUCT_NAME = Cache; SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -1333,6 +1621,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 285DC47E2BB2CFCC0036F206 /* Build configuration list for PBXNativeTarget "Cache-watchOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 285DC47F2BB2CFCC0036F206 /* Debug */, + 285DC4802BB2CFCC0036F206 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; BDEDD35D1DBCE5B1007416A6 /* Build configuration list for PBXNativeTarget "Cache-tvOS" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme b/Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme index fc762f31..2938ef18 100644 --- a/Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme +++ b/Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme @@ -1,6 +1,6 @@ (toData: toData, fromData: fromData) } - #if os(iOS) || os(tvOS) || os(macOS) || os(visionOS) public static func forImage() -> Transformer { let toData: (Image) throws -> Data = { image in return try image.cache_toData().unwrapOrThrow(error: StorageError.transformerFail) @@ -21,7 +24,6 @@ public class TransformerFactory { return Transformer(toData: toData, fromData: fromData) } - #endif public static func forCodable(ofType: U.Type) -> Transformer { let toData: (U) throws -> Data = { object in diff --git a/Source/Shared/Library/Types.swift b/Source/Shared/Library/Types.swift index e8408db4..44d6265c 100644 --- a/Source/Shared/Library/Types.swift +++ b/Source/Shared/Library/Types.swift @@ -1,7 +1,6 @@ -#if os(iOS) || os(tvOS) || os(visionOS) +#if canImport(UIKit) import UIKit public typealias Image = UIImage -#elseif os(watchOS) #elseif os(OSX) import AppKit diff --git a/Source/Shared/Storage/DiskStorage.swift b/Source/Shared/Storage/DiskStorage.swift index b0bf9e37..78d9b733 100644 --- a/Source/Shared/Storage/DiskStorage.swift +++ b/Source/Shared/Storage/DiskStorage.swift @@ -39,14 +39,11 @@ final public class DiskStorage { try createDirectory() - // protection - #if os(iOS) || os(tvOS) if let protectionType = config.protectionType { try setDirectoryAttributes([ FileAttributeKey.protectionKey: protectionType ]) } - #endif } public required init(config: DiskConfig, fileManager: FileManager = FileManager.default, path: String, transformer: Transformer) { diff --git a/Source/Shared/Storage/Storage+Transform.swift b/Source/Shared/Storage/Storage+Transform.swift index 494e6afb..d043a5d3 100644 --- a/Source/Shared/Storage/Storage+Transform.swift +++ b/Source/Shared/Storage/Storage+Transform.swift @@ -1,3 +1,7 @@ +#if canImport(UIKit) +import UIKit +#endif + import Foundation public extension Storage { @@ -7,12 +11,10 @@ public extension Storage { } - #if os(iOS) || os(tvOS) || os(macOS) func transformImage() -> Storage { let storage = transform(transformer: TransformerFactory.forImage()) return storage } - #endif func transformCodable(ofType: U.Type) -> Storage { let storage = transform(transformer: TransformerFactory.forCodable(ofType: U.self)) diff --git a/Tests/Shared/TestHelper.swift b/Tests/Shared/TestHelper.swift index 07b42d25..9c34eab7 100644 --- a/Tests/Shared/TestHelper.swift +++ b/Tests/Shared/TestHelper.swift @@ -1,8 +1,8 @@ import Foundation -#if os(iOS) || os(tvOS) +#if canImport(UIKit) import UIKit -#elseif os(OSX) +#elseif os(macOS) import AppKit #endif @@ -13,7 +13,7 @@ struct TestHelper { } static func triggerApplicationEvents() { - #if os(iOS) || os(tvOS) + #if os(iOS) || os(tvOS) || os(visionOS) NotificationCenter.default.post(name: UIApplication.didEnterBackgroundNotification, object: nil) NotificationCenter.default.post(name: UIApplication.willTerminateNotification, object: nil) #elseif os(macOS) diff --git a/Tests/iOS/Helpers/TestHelper+iOS.swift b/Tests/iOS/Helpers/TestHelper+iOS.swift index ab840d04..9bb32afe 100644 --- a/Tests/iOS/Helpers/TestHelper+iOS.swift +++ b/Tests/iOS/Helpers/TestHelper+iOS.swift @@ -1,4 +1,4 @@ -#if os(iOS) || os(tvOS) +#if canImport(UIKit) import UIKit extension TestHelper { diff --git a/Tests/iOS/Helpers/UIImage+ExtensionsTests.swift b/Tests/iOS/Helpers/UIImage+ExtensionsTests.swift index 307a0578..97e2be7e 100644 --- a/Tests/iOS/Helpers/UIImage+ExtensionsTests.swift +++ b/Tests/iOS/Helpers/UIImage+ExtensionsTests.swift @@ -1,4 +1,4 @@ -#if os(iOS) || os(tvOS) +#if canImport(UIKit) import UIKit extension UIImage { From f44a8f6b5ec27730198725ccc542fef0d1cc6b3d Mon Sep 17 00:00:00 2001 From: Elvis <3lvis@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:26:39 +0100 Subject: [PATCH 18/31] Update Cache.podspec --- Cache.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cache.podspec b/Cache.podspec index 29f1b3c1..4698519b 100644 --- a/Cache.podspec +++ b/Cache.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Cache" s.summary = "Nothing but cache." - s.version = "7.0.1" + s.version = "7.1.0" s.homepage = "https://github.com/hyperoslo/Cache" s.license = 'MIT' s.author = { "Hyper Interaktiv AS" => "ios@hyper.no" } From 3fdb0aa24a4ba189564507764245adad36dc105a Mon Sep 17 00:00:00 2001 From: Keita Watanabe Date: Sun, 26 May 2024 16:14:14 +0900 Subject: [PATCH 19/31] add async await --- Source/Shared/Storage/AsyncStorage.swift | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/Source/Shared/Storage/AsyncStorage.swift b/Source/Shared/Storage/AsyncStorage.swift index 4f1c1b04..42becd76 100644 --- a/Source/Shared/Storage/AsyncStorage.swift +++ b/Source/Shared/Storage/AsyncStorage.swift @@ -138,3 +138,65 @@ public extension AsyncStorage { return storage } } + +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) +public extension AsyncStorage { + func entry(forKey key: Key) async throws -> Entry { + try await withCheckedThrowingContinuation { continuation in + entry(forKey: key) { + continuation.resume(with: $0) + } + } + } + + func removeObject(forKey key: Key) async throws { + try await withCheckedThrowingContinuation { continuation in + removeObject(forKey: key) { + continuation.resume(with: $0) + } + } + } + + func setObject( + _ object: Value, + forKey key: Key, + expiry: Expiry? = nil) async throws { + try await withCheckedThrowingContinuation { continuation in + setObject(object, forKey: key, expiry: expiry) { + continuation.resume(with: $0) + } + } + } + + func removeAll() async throws { + try await withCheckedThrowingContinuation { continuation in + removeAll { + continuation.resume(with: $0) + } + } + } + + func removeExpiredObjects() async throws { + try await withCheckedThrowingContinuation { continuation in + removeExpiredObjects { + continuation.resume(with: $0) + } + } + } + + func object(forKey key: Key) async throws -> Value { + try await withCheckedThrowingContinuation { continuation in + object(forKey: key) { + continuation.resume(with: $0) + } + } + } + + func objectExists(forKey key: Key) async throws -> Bool { + try await withCheckedThrowingContinuation { continuation in + objectExists(forKey: key) { + continuation.resume(with: $0) + } + } + } +} From 91ac56f4cd4a7dbb6490d41989636a960a8d165c Mon Sep 17 00:00:00 2001 From: Keita Watanabe Date: Sun, 26 May 2024 16:41:08 +0900 Subject: [PATCH 20/31] add tests --- Tests/Shared/TestCase+Extensions.swift | 12 +++++++++ .../iOS/Tests/Storage/AsyncStorageTests.swift | 27 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Tests/Shared/TestCase+Extensions.swift b/Tests/Shared/TestCase+Extensions.swift index c3ba232e..8174187b 100644 --- a/Tests/Shared/TestCase+Extensions.swift +++ b/Tests/Shared/TestCase+Extensions.swift @@ -5,11 +5,23 @@ extension XCTestCase { try closure() } + func given(_ description: String, closure: () async throws -> Void) async rethrows { + try await closure() + } + func when(_ description: String, closure: () throws -> Void) rethrows { try closure() } + func when(_ description: String, closure: () async throws -> Void) async rethrows { + try await closure() + } + func then(_ description: String, closure: () throws -> Void) rethrows { try closure() } + + func then(_ description: String, closure: () async throws -> Void) async rethrows { + try await closure() + } } diff --git a/Tests/iOS/Tests/Storage/AsyncStorageTests.swift b/Tests/iOS/Tests/Storage/AsyncStorageTests.swift index 1251d152..eb268d20 100644 --- a/Tests/iOS/Tests/Storage/AsyncStorageTests.swift +++ b/Tests/iOS/Tests/Storage/AsyncStorageTests.swift @@ -36,6 +36,13 @@ final class AsyncStorageTests: XCTestCase { wait(for: [expectation], timeout: 1) } + func testSetObject() async throws { + try await storage.setObject(user, forKey: "user") + let cachedUser = try await storage.object(forKey: "user") + + XCTAssertEqual(cachedUser, self.user) + } + func testRemoveAll() { let intStorage = storage.transform(transformer: TransformerFactory.forCodable(ofType: Int.self)) let expectation = self.expectation(description: #function) @@ -62,4 +69,24 @@ final class AsyncStorageTests: XCTestCase { wait(for: [expectation], timeout: 1) } + + func testRemoveAll() async throws { + let intStorage = storage.transform(transformer: TransformerFactory.forCodable(ofType: Int.self)) + try await given("add a lot of objects") { + for i in 0 ..< 100 { + try await intStorage.setObject(i, forKey: "key-\(i)") + } + } + + try await when("remove all") { + try await intStorage.removeAll() + } + + await then("all are removed") { + do { + _ = try await intStorage.objectExists(forKey: "key-99") + XCTFail() + } catch {} + } + } } From 62374db4d1916e808f81a22cec7eeb964f501d9b Mon Sep 17 00:00:00 2001 From: Keita Watanabe Date: Sun, 26 May 2024 16:50:57 +0900 Subject: [PATCH 21/31] add example for async await into readme --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index ee260ebf..cb6805db 100644 --- a/README.md +++ b/README.md @@ -288,6 +288,45 @@ storage.async.removeExpiredObjects() { result in } ``` +#### Swift Concurrency + +```swift +do { + try await storage.async.setObject("Oslo", forKey: "my favorite city") + print("saved successfully") +} catch { + print(error) +} + +do { + let city = try await storage.async.object(forKey: "my favorite city") + print("my favorite city is \(city)") +} catch { + print(error) +} + +do { + let exists = try await storage.async.objectExists(forKey: "my favorite city") + if exists { + print("I have a favorite city") + } +} catch {} + +do { + try await storage.async.remoeAll() + print("removal completes") +} catch { + print(error) +} + +do { + try await storage.async.removeExpiredObjects() + print("removal completes") +} catch { + print(error) +} +``` + ### Expiry date By default, all saved objects have the same expiry as the expiry you specify in `DiskConfig` or `MemoryConfig`. You can overwrite this for a specific object by specifying `expiry` for `setObject` From 4740e2ef873ff3e1f3a117c7084002daf29f3178 Mon Sep 17 00:00:00 2001 From: Keita Watanabe Date: Sun, 26 May 2024 16:58:40 +0900 Subject: [PATCH 22/31] fix readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ee260ebf..3cb9968b 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ let score = try? storage.object(forKey: "score") let favoriteCharacter = try? storage.object(forKey: "my favorite city") // Check if an object exists -let hasFavoriteCharacter = try? storage.existsObject(forKey: "my favorite city") +let hasFavoriteCharacter = try? storage.objectExists(forKey: "my favorite city") // Remove an object in storage try? storage.removeObject(forKey: "my favorite city") @@ -263,7 +263,7 @@ storage.async.object(forKey: "my favorite city") { result in } } -storage.async.existsObject(forKey: "my favorite city") { result in +storage.async.objectExists(forKey: "my favorite city") { result in if case .success(let exists) = result, exists { print("I have a favorite city") } @@ -299,7 +299,7 @@ try? storage.setObject("This is a string", forKey: "string") // A given expiry date will be applied to the item try? storage.setObject( "This is a string", - forKey: "string" + forKey: "string", expiry: .date(Date().addingTimeInterval(2 * 3600)) ) From fd97438a85d44aa4f7186145cdba90e3c36f1c94 Mon Sep 17 00:00:00 2001 From: Elvis Date: Sun, 26 May 2024 23:01:33 +0200 Subject: [PATCH 23/31] Fix tests --- Tests/iOS/Tests/Storage/AsyncStorageTests.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/iOS/Tests/Storage/AsyncStorageTests.swift b/Tests/iOS/Tests/Storage/AsyncStorageTests.swift index eb268d20..fb5023e7 100644 --- a/Tests/iOS/Tests/Storage/AsyncStorageTests.swift +++ b/Tests/iOS/Tests/Storage/AsyncStorageTests.swift @@ -36,6 +36,7 @@ final class AsyncStorageTests: XCTestCase { wait(for: [expectation], timeout: 1) } +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) func testSetObject() async throws { try await storage.setObject(user, forKey: "user") let cachedUser = try await storage.object(forKey: "user") @@ -70,6 +71,7 @@ final class AsyncStorageTests: XCTestCase { wait(for: [expectation], timeout: 1) } +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) func testRemoveAll() async throws { let intStorage = storage.transform(transformer: TransformerFactory.forCodable(ofType: Int.self)) try await given("add a lot of objects") { From f7805bacdb5d9ebd81212f1fb4b9a75995aca148 Mon Sep 17 00:00:00 2001 From: Lucas Romano Date: Tue, 18 Jun 2024 18:57:24 -0300 Subject: [PATCH 24/31] Fix xcprivacy on podscpec Fix xcprivacy on podspec --- Cache.podspec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Cache.podspec b/Cache.podspec index 4698519b..39f5378e 100644 --- a/Cache.podspec +++ b/Cache.podspec @@ -17,8 +17,7 @@ Pod::Spec.new do |s| s.ios.source_files = 'Source/{iOS,Shared}/**/*' s.osx.source_files = 'Source/{Mac,Shared}/**/*' s.tvos.source_files = 'Source/{iOS,Shared}/**/*' - s.resources = 'Source/PrivacyInfo.xcprivacy' - + s.resource_bundles = { 'Cache_privacy' => 'Source/PrivacyInfo.xcprivacy' } s.frameworks = 'Foundation' s.swift_version = '5.0' end From 5b044183d53831da7a69682ad24b8ff05efa9e10 Mon Sep 17 00:00:00 2001 From: Ken Carroll Date: Thu, 18 Jul 2024 12:56:40 +0100 Subject: [PATCH 25/31] Set attributes of files created --- Source/Shared/Storage/DiskStorage.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Source/Shared/Storage/DiskStorage.swift b/Source/Shared/Storage/DiskStorage.swift index 78d9b733..c47be1fd 100644 --- a/Source/Shared/Storage/DiskStorage.swift +++ b/Source/Shared/Storage/DiskStorage.swift @@ -17,9 +17,11 @@ final public class DiskStorage { private let transformer: Transformer private let hasher = Hasher.constantAccrossExecutions() + private var defaultFileAttributes: [FileAttributeKey : Any]? // MARK: - Initialization - public convenience init(config: DiskConfig, fileManager: FileManager = FileManager.default, transformer: Transformer) throws { + public convenience init(config: DiskConfig, fileManager: FileManager = FileManager.default, transformer: Transformer, + fileAttributes: [FileAttributeKey : Any] = [:]) throws { let url: URL if let directory = config.directory { url = directory @@ -44,6 +46,9 @@ final public class DiskStorage { FileAttributeKey.protectionKey: protectionType ]) } + + defaultFileAttributes = fileAttributes + } public required init(config: DiskConfig, fileManager: FileManager = FileManager.default, path: String, transformer: Transformer) { @@ -80,8 +85,11 @@ extension DiskStorage: StorageAware { let expiry = expiry ?? config.expiry let data = try transformer.toData(object) let filePath = makeFilePath(for: key) - _ = fileManager.createFile(atPath: filePath, contents: data, attributes: nil) - try fileManager.setAttributes([.modificationDate: expiry.date], ofItemAtPath: filePath) + var attributes = defaultFileAttributes! + attributes[.modificationDate] = expiry.date + + _ = fileManager.createFile(atPath: filePath, contents: data, attributes: attributes) +// try fileManager.setAttributes([.modificationDate: expiry.date], ofItemAtPath: filePath) } public func removeObject(forKey key: Key) throws { From db45d9f4b1a7b80df1b96adb168861126b7983d0 Mon Sep 17 00:00:00 2001 From: Ken Carroll Date: Thu, 18 Jul 2024 13:21:51 +0100 Subject: [PATCH 26/31] Use FileManager instead of attributes. --- Source/Shared/Storage/DiskStorage.swift | 17 ++++++++--------- Source/Shared/Storage/Storage.swift | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Source/Shared/Storage/DiskStorage.swift b/Source/Shared/Storage/DiskStorage.swift index c47be1fd..a5c68167 100644 --- a/Source/Shared/Storage/DiskStorage.swift +++ b/Source/Shared/Storage/DiskStorage.swift @@ -17,11 +17,10 @@ final public class DiskStorage { private let transformer: Transformer private let hasher = Hasher.constantAccrossExecutions() - private var defaultFileAttributes: [FileAttributeKey : Any]? +// private var defaultFileAttributes: [FileAttributeKey : Any]? // MARK: - Initialization - public convenience init(config: DiskConfig, fileManager: FileManager = FileManager.default, transformer: Transformer, - fileAttributes: [FileAttributeKey : Any] = [:]) throws { + public convenience init(config: DiskConfig, fileManager: FileManager = FileManager.default, transformer: Transformer) throws { let url: URL if let directory = config.directory { url = directory @@ -47,7 +46,7 @@ final public class DiskStorage { ]) } - defaultFileAttributes = fileAttributes +// defaultFileAttributes = fileAttributes } @@ -85,11 +84,11 @@ extension DiskStorage: StorageAware { let expiry = expiry ?? config.expiry let data = try transformer.toData(object) let filePath = makeFilePath(for: key) - var attributes = defaultFileAttributes! - attributes[.modificationDate] = expiry.date - - _ = fileManager.createFile(atPath: filePath, contents: data, attributes: attributes) -// try fileManager.setAttributes([.modificationDate: expiry.date], ofItemAtPath: filePath) +// var attributes = defaultFileAttributes! +// attributes[.modificationDate] = expiry.date +// + _ = fileManager.createFile(atPath: filePath, contents: data, attributes: nil) + try fileManager.setAttributes([.modificationDate: expiry.date], ofItemAtPath: filePath) } public func removeObject(forKey key: Key) throws { diff --git a/Source/Shared/Storage/Storage.swift b/Source/Shared/Storage/Storage.swift index 12b567f1..4f94c86f 100644 --- a/Source/Shared/Storage/Storage.swift +++ b/Source/Shared/Storage/Storage.swift @@ -15,8 +15,8 @@ public final class Storage { /// - diskConfig: Configuration for disk storage /// - memoryConfig: Optional. Pass config if you want memory cache /// - Throws: Throw StorageError if any. - public convenience init(diskConfig: DiskConfig, memoryConfig: MemoryConfig, transformer: Transformer) throws { - let disk = try DiskStorage(config: diskConfig, transformer: transformer) + public convenience init(diskConfig: DiskConfig, memoryConfig: MemoryConfig, fileManager: FileManager, transformer: Transformer) throws { + let disk = try DiskStorage(config: diskConfig, fileManager: fileManager, transformer: transformer) let memory = MemoryStorage(config: memoryConfig) let hybridStorage = HybridStorage(memoryStorage: memory, diskStorage: disk) self.init(hybridStorage: hybridStorage) From e2a8f2f01e8755d2d70ac4c082a24ef0ecf0de84 Mon Sep 17 00:00:00 2001 From: Ken Carroll Date: Thu, 18 Jul 2024 14:01:28 +0100 Subject: [PATCH 27/31] Remove unused code. --- Source/Shared/Storage/DiskStorage.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/Shared/Storage/DiskStorage.swift b/Source/Shared/Storage/DiskStorage.swift index a5c68167..7bc36b6a 100644 --- a/Source/Shared/Storage/DiskStorage.swift +++ b/Source/Shared/Storage/DiskStorage.swift @@ -17,7 +17,6 @@ final public class DiskStorage { private let transformer: Transformer private let hasher = Hasher.constantAccrossExecutions() -// private var defaultFileAttributes: [FileAttributeKey : Any]? // MARK: - Initialization public convenience init(config: DiskConfig, fileManager: FileManager = FileManager.default, transformer: Transformer) throws { @@ -84,9 +83,6 @@ extension DiskStorage: StorageAware { let expiry = expiry ?? config.expiry let data = try transformer.toData(object) let filePath = makeFilePath(for: key) -// var attributes = defaultFileAttributes! -// attributes[.modificationDate] = expiry.date -// _ = fileManager.createFile(atPath: filePath, contents: data, attributes: nil) try fileManager.setAttributes([.modificationDate: expiry.date], ofItemAtPath: filePath) } From ddce7b991650422444a4cae19f47a8e1081188a3 Mon Sep 17 00:00:00 2001 From: Ken Carroll Date: Thu, 18 Jul 2024 14:15:11 +0100 Subject: [PATCH 28/31] Delete commented line of code. --- Source/Shared/Storage/DiskStorage.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/Shared/Storage/DiskStorage.swift b/Source/Shared/Storage/DiskStorage.swift index 7bc36b6a..78d9b733 100644 --- a/Source/Shared/Storage/DiskStorage.swift +++ b/Source/Shared/Storage/DiskStorage.swift @@ -44,9 +44,6 @@ final public class DiskStorage { FileAttributeKey.protectionKey: protectionType ]) } - -// defaultFileAttributes = fileAttributes - } public required init(config: DiskConfig, fileManager: FileManager = FileManager.default, path: String, transformer: Transformer) { From c07b1b8a9ebb9bdfbf9276a95435e8b625a030ed Mon Sep 17 00:00:00 2001 From: Lucas Romano Date: Tue, 27 Aug 2024 16:16:37 -0300 Subject: [PATCH 29/31] Update Cache.podspec --- Cache.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cache.podspec b/Cache.podspec index 39f5378e..c338e030 100644 --- a/Cache.podspec +++ b/Cache.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Cache" s.summary = "Nothing but cache." - s.version = "7.1.0" + s.version = "7.4.0" s.homepage = "https://github.com/hyperoslo/Cache" s.license = 'MIT' s.author = { "Hyper Interaktiv AS" => "ios@hyper.no" } From bb7a3b7b090ec3614ca92f3eb847bdf742f722dd Mon Sep 17 00:00:00 2001 From: gibachan Date: Tue, 17 Dec 2024 09:24:08 +0900 Subject: [PATCH 30/31] Fix unit test --- Tests/iOS/Tests/Storage/StorageTests.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/iOS/Tests/Storage/StorageTests.swift b/Tests/iOS/Tests/Storage/StorageTests.swift index 80f3f18e..ec5e9ea2 100644 --- a/Tests/iOS/Tests/Storage/StorageTests.swift +++ b/Tests/iOS/Tests/Storage/StorageTests.swift @@ -2,6 +2,7 @@ import XCTest @testable import Cache final class StorageTests: XCTestCase { + private let fileManager = FileManager() private var storage: Storage! let user = User(firstName: "John", lastName: "Snow") @@ -11,6 +12,7 @@ final class StorageTests: XCTestCase { storage = try! Storage( diskConfig: DiskConfig(name: "Thor"), memoryConfig: MemoryConfig(), + fileManager: fileManager, transformer: TransformerFactory.forCodable(ofType: User.self) ) } From 12c81c30c177c7b73fe74ede562f41a40dee5ef6 Mon Sep 17 00:00:00 2001 From: Mack Hasz Date: Thu, 28 Aug 2025 16:28:29 -0400 Subject: [PATCH 31/31] Update Storage.swift --- Source/Shared/Storage/Storage.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Shared/Storage/Storage.swift b/Source/Shared/Storage/Storage.swift index 4f94c86f..c6799cd4 100644 --- a/Source/Shared/Storage/Storage.swift +++ b/Source/Shared/Storage/Storage.swift @@ -15,7 +15,7 @@ public final class Storage { /// - diskConfig: Configuration for disk storage /// - memoryConfig: Optional. Pass config if you want memory cache /// - Throws: Throw StorageError if any. - public convenience init(diskConfig: DiskConfig, memoryConfig: MemoryConfig, fileManager: FileManager, transformer: Transformer) throws { + public convenience init(diskConfig: DiskConfig, memoryConfig: MemoryConfig, fileManager: FileManager = FileManager.default, transformer: Transformer) throws { let disk = try DiskStorage(config: diskConfig, fileManager: fileManager, transformer: transformer) let memory = MemoryStorage(config: memoryConfig) let hybridStorage = HybridStorage(memoryStorage: memory, diskStorage: disk)