diff --git a/.circleci/config.yml b/.circleci/config.yml index 2e638711..23597874 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,19 +2,19 @@ version: 2 jobs: build-and-test: macos: - xcode: "9.3.0" + xcode: "10.0.0" shell: /bin/bash --login -o pipefail steps: - checkout - run: xcodebuild -project Cache.xcodeproj -scheme "Cache-macOS" -sdk macosx clean - run: xcodebuild -project Cache.xcodeproj -scheme "Cache-macOS" -sdk macosx -enableCodeCoverage YES test - run: xcodebuild -project Cache.xcodeproj -scheme "Cache-iOS" -sdk iphonesimulator clean - - run: xcodebuild -project Cache.xcodeproj -scheme "Cache-iOS" -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=11.3,name=iPhone X' -enableCodeCoverage YES test - - run: xcodebuild -project Cache.xcodeproj -scheme "Cache-tvOS" -destination 'platform=tvOS Simulator,name=Apple TV,OS=11.3' clean - - run: xcodebuild -project Cache.xcodeproj -scheme "Cache-tvOS" -destination 'platform=tvOS Simulator,name=Apple TV,OS=11.3' -enableCodeCoverage YES test + - run: xcodebuild -project Cache.xcodeproj -scheme "Cache-iOS" -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=12.0,name=iPhone X' -enableCodeCoverage YES test + - run: xcodebuild -project Cache.xcodeproj -scheme "Cache-tvOS" -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' clean + - run: xcodebuild -project Cache.xcodeproj -scheme "Cache-tvOS" -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' -enableCodeCoverage YES test workflows: version: 2 build-and-test: jobs: - - build-and-test \ No newline at end of file + - build-and-test diff --git a/.swift-version b/.swift-version index 7d5c902e..bf77d549 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.1 +4.2 diff --git a/Cache.podspec b/Cache.podspec index 03a9cc37..7472be14 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 = "5.1.0" + s.version = "5.1.1" s.homepage = "https://github.com/hyperoslo/Cache" s.license = 'MIT' s.author = { "Hyper Interaktiv AS" => "ios@hyper.no" } @@ -19,5 +19,5 @@ Pod::Spec.new do |s| s.frameworks = 'Foundation' - s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.1' } + s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.2' } end diff --git a/Cache.xcodeproj/project.pbxproj b/Cache.xcodeproj/project.pbxproj index be257cbf..4074dd71 100644 --- a/Cache.xcodeproj/project.pbxproj +++ b/Cache.xcodeproj/project.pbxproj @@ -497,7 +497,9 @@ D5DC59FA1C205AC9003BD79B /* Tests */, D5DC59E11C20593E003BD79B /* Products */, ); + indentWidth = 4; sourceTree = ""; + tabWidth = 4; }; D5DC59E11C20593E003BD79B /* Products */ = { isa = PBXGroup; @@ -1109,7 +1111,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-iOS-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -1122,7 +1124,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-iOS-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme b/Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme index 637c74b1..d05b90d7 100644 --- a/Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme +++ b/Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme @@ -29,7 +29,9 @@ shouldUseLaunchSchemeArgsEnv = "YES"> + skipped = "NO" + parallelizable = "YES" + testExecutionOrdering = "random"> + skipped = "NO" + parallelizable = "YES" + testExecutionOrdering = "random"> + skipped = "NO" + parallelizable = "YES" + testExecutionOrdering = "random"> { var onRemove: ((String) -> Void)? private let transformer: Transformer - - // MARK: - Initialization + // MARK: - Initialization public convenience init(config: DiskConfig, fileManager: FileManager = FileManager.default, transformer: Transformer) throws { let url: URL if let directory = config.directory { diff --git a/Source/Shared/Storage/HybridStorage.swift b/Source/Shared/Storage/HybridStorage.swift index 5e96fbce..52909680 100644 --- a/Source/Shared/Storage/HybridStorage.swift +++ b/Source/Shared/Storage/HybridStorage.swift @@ -109,7 +109,7 @@ extension HybridStorage: StorageObservationRegistry { self?.storageObservations.removeValue(forKey: id) } } - + public func removeAllStorageObservers() { storageObservations.removeAll() } @@ -155,7 +155,7 @@ extension HybridStorage: KeyObservationRegistry { } private func notifyObserver(about change: KeyChange, whereKey closure: ((String) -> Bool)) { - let observation = keyObservations.first { key, value in closure(key) }?.value + let observation = keyObservations.first { key, _ in closure(key) }?.value observation?(self, change) } diff --git a/Source/Shared/Storage/Storage.swift b/Source/Shared/Storage/Storage.swift index 63e0a698..71a4c2ec 100644 --- a/Source/Shared/Storage/Storage.swift +++ b/Source/Shared/Storage/Storage.swift @@ -94,7 +94,7 @@ extension Storage: KeyObservationRegistry { forKey key: String, closure: @escaping (O, Storage, KeyChange) -> Void ) -> ObservationToken { - return hybridStorage.addObserver(observer, forKey: key) { [weak self] observer, _ , change in + return hybridStorage.addObserver(observer, forKey: key) { [weak self] observer, _, change in guard let strongSelf = self else { return } closure(observer, strongSelf, change) } diff --git a/Tests/Shared/TestHelper.swift b/Tests/Shared/TestHelper.swift index ac2be5ac..8f01c0e9 100644 --- a/Tests/Shared/TestHelper.swift +++ b/Tests/Shared/TestHelper.swift @@ -13,9 +13,12 @@ struct TestHelper { } static func triggerApplicationEvents() { - #if !os(macOS) - NotificationCenter.default.post(name: .UIApplicationDidEnterBackground, object: nil) - NotificationCenter.default.post(name: .UIApplicationWillTerminate, object: nil) + #if (iOS) + NotificationCenter.default.post(name: UIApplication.didEnterBackgroundNotification, object: nil) + NotificationCenter.default.post(name: UIApplication.willTerminateNotification, object: nil) + #elseif os(tvOS) + NotificationCenter.default.post(name: Notification.Name.UIApplicationDidEnterBackground, object: nil) + NotificationCenter.default.post(name: Notification.Name.UIApplicationWillTerminate, object: nil) #else NotificationCenter.default.post(name: NSApplication.willTerminateNotification, object: nil) NotificationCenter.default.post(name: NSApplication.didResignActiveNotification, object: nil)