Skip to content

Commit

Permalink
Merge pull request hyperoslo#216 from fassko/master
Browse files Browse the repository at this point in the history
Swift 4.2 and Xcode 10 improvements
  • Loading branch information
onmyway133 committed Sep 23, 2018
2 parents 1664e8a + 3453f68 commit 31f444c
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 29 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- build-and-test
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1
4.2
4 changes: 2 additions & 2 deletions Cache.podspec
Original file line number Diff line number Diff line change
@@ -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" }
Expand All @@ -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
6 changes: 4 additions & 2 deletions Cache.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,9 @@
D5DC59FA1C205AC9003BD79B /* Tests */,
D5DC59E11C20593E003BD79B /* Products */,
);
indentWidth = 4;
sourceTree = "<group>";
tabWidth = 4;
};
D5DC59E11C20593E003BD79B /* Products */ = {
isa = PBXGroup;
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
4 changes: 3 additions & 1 deletion Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
skipped = "NO"
parallelizable = "YES"
testExecutionOrdering = "random">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D5291D171C2837DB00B702C9"
Expand Down
4 changes: 3 additions & 1 deletion Cache.xcodeproj/xcshareddata/xcschemes/Cache-macOS.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
skipped = "NO"
parallelizable = "YES"
testExecutionOrdering = "random">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D5291D681C283B5400B702C9"
Expand Down
4 changes: 3 additions & 1 deletion Cache.xcodeproj/xcshareddata/xcschemes/Cache-tvOS.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
skipped = "NO"
parallelizable = "YES"
testExecutionOrdering = "random">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BDEDD3771DBCEB8A007416A6"
Expand Down
10 changes: 2 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
// swift-tools-version:4.2

import PackageDescription

let package = Package(
name: "Cache",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Cache",
targets: ["Cache"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
],
dependencies: [],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Cache",
path: "Source/Shared",
Expand Down
3 changes: 1 addition & 2 deletions Source/Shared/Storage/DiskStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ final public class DiskStorage<T> {
var onRemove: ((String) -> Void)?

private let transformer: Transformer<T>

// MARK: - Initialization

// MARK: - Initialization
public convenience init(config: DiskConfig, fileManager: FileManager = FileManager.default, transformer: Transformer<T>) throws {
let url: URL
if let directory = config.directory {
Expand Down
4 changes: 2 additions & 2 deletions Source/Shared/Storage/HybridStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ extension HybridStorage: StorageObservationRegistry {
self?.storageObservations.removeValue(forKey: id)
}
}

public func removeAllStorageObservers() {
storageObservations.removeAll()
}
Expand Down Expand Up @@ -155,7 +155,7 @@ extension HybridStorage: KeyObservationRegistry {
}

private func notifyObserver(about change: KeyChange<T>, 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)
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/Storage/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ extension Storage: KeyObservationRegistry {
forKey key: String,
closure: @escaping (O, Storage, KeyChange<T>) -> 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)
}
Expand Down
9 changes: 6 additions & 3 deletions Tests/Shared/TestHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 31f444c

Please sign in to comment.