Skip to content

Commit

Permalink
Resolve Xcode 10.2 warnings with Swift 4.2.2 and 5.0 (ReSwift#397)
Browse files Browse the repository at this point in the history
Resolves ReSwift#396

* Resolve Xcode 10.2 Warnings with Swift 4.2.2
* Resolve Xcode 10.2 Warnings with Swift 5.0
* Update Changelog
* Update supported swift versions in README

Due to conditional conformance the latest ReSwift still works great going all the way back to Swift 3.2.

* Configure Travis CI to validate Swift 4.2.2 & 5.0 compatibility

Only adds jobs for the macOS tests, since Xcode 10.2 is still in beta. Once released, we'll migrate our cross-platform tests up to 10.2, leaving in a compatibility test for 10.1.

* Configure Travis CI to use Xcode 10.2 as primary

Since Xcode 10.2 is now out of beta, we can switch our primary tests over to it. (even though travis is still using the beta, it will update automatically when they switch)

* Update local Swiftlint version, resolve warnings.

Pins swiftlint to the same version hound ci supports.

http://help.houndci.com/configuration/supported-linters
  • Loading branch information
mjarvis authored Apr 29, 2019
1 parent 941d85d commit 83da0e5
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 59 deletions.
16 changes: 10 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ matrix:
env: SCHEME="macOS" SDK="macosx10.13" DESTINATION="arch=x86_64" SWIFT_VERSION="4.1" ACTION="test"
- osx_image: xcode10.1
env: SCHEME="macOS" SDK="macosx10.14" DESTINATION="arch=x86_64" SWIFT_VERSION="4.2" ACTION="test"
- osx_image: xcode10.1
env: SCHEME="iOS" SDK="iphonesimulator" DESTINATION="OS=12.0,name=iPhone 8" SWIFT_VERSION="4.2" ACTION="test"
- osx_image: xcode10.1
env: SCHEME="watchOS" SDK="watchsimulator" DESTINATION="OS=4.0,name=Apple Watch - 42mm" SWIFT_VERSION="4.2" ACTION="build"
- osx_image: xcode10.1
env: SCHEME="tvOS" SDK="appletvsimulator" DESTINATION="OS=12.0,name=Apple TV 4K" SWIFT_VERSION="4.2" ACTION="test"
- osx_image: xcode10.2
env: SCHEME="macOS" SDK="macosx10.14" DESTINATION="arch=x86_64" SWIFT_VERSION="4.2" ACTION="test"
- osx_image: xcode10.2
env: SCHEME="iOS" SDK="iphonesimulator" DESTINATION="OS=12.2,name=iPhone 8" SWIFT_VERSION="4.2" ACTION="test"
- osx_image: xcode10.2
env: SCHEME="watchOS" SDK="watchsimulator" DESTINATION="OS=5.2,name=Apple Watch Series 4 - 44mm" SWIFT_VERSION="4.2" ACTION="build"
- osx_image: xcode10.2
env: SCHEME="tvOS" SDK="appletvsimulator" DESTINATION="OS=12.2,name=Apple TV 4K" SWIFT_VERSION="4.2" ACTION="test"
- osx_image: xcode10.2
env: SCHEME="macOS" SDK="macosx10.14" DESTINATION="arch=x86_64" SWIFT_VERSION="5.0" ACTION="test"
- osx_image: xcode10.2
env: SCHEME="macOS" SDK="macosx10.14" DESTINATION="arch=x86_64" TEST_SWIFTPM="true"

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- This deprecates the usage of `ReSwift-Recorder`. Changes may be made to that library in the future in order to support this change.

**Other:**
- Resolve Xcode 10.2 warnings with Swift 4.2.2 and 5.0 (#397) - @mjarvis
- Update Swift Package Manager support (#403) - @Dschee

# 4.1.1
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# any of the actual ReSwift targets dirty or bloated a dummy target called
# SwiftLintIntegration has been added.
target 'SwiftLintIntegration' do
pod 'SwiftLint'
pod 'SwiftLint', '~> 0.27.0'
end
14 changes: 9 additions & 5 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
PODS:
- SwiftLint (0.22.0)
- SwiftLint (0.27.0)

DEPENDENCIES:
- SwiftLint
- SwiftLint (~> 0.27.0)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- SwiftLint

SPEC CHECKSUMS:
SwiftLint: 1134786caedd2caab0560d2f36b76414a5a56808
SwiftLint: 3207c1faa2240bf8973b191820a116113cd11073

PODFILE CHECKSUM: 937d436496e317ef5f238fab841c0529d8f5d201
PODFILE CHECKSUM: 7bbdd45b8293c884aa09eb64369012f08940f4f7

COCOAPODS: 1.3.1
COCOAPODS: 1.6.1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://img.shields.io/travis/ReSwift/ReSwift/master.svg?style=flat-square)](https://travis-ci.org/ReSwift/ReSwift) [![Code coverage status](https://img.shields.io/codecov/c/github/ReSwift/ReSwift.svg?style=flat-square)](http://codecov.io/github/ReSwift/ReSwift) [![CocoaPods Compatible](https://img.shields.io/cocoapods/v/ReSwift.svg?style=flat-square)](https://cocoapods.org/pods/ReSwift) [![Platform support](https://img.shields.io/badge/platform-ios%20%7C%20osx%20%7C%20tvos%20%7C%20watchos-lightgrey.svg?style=flat-square)](https://github.com/ReSwift/ReSwift/blob/master/LICENSE.md) [![License MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/ReSwift/ReSwift/blob/master/LICENSE.md) [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg?style=flat-square)](https://houndci.com)

**Supported Swift Versions:** Swift 3.2, 4.0
**Supported Swift Versions:** Swift 3.2, 4.0, 4.2, 5.0

For Swift 2.2 Support use [Release 2.0.0](https://github.com/ReSwift/ReSwift/releases/tag/2.0.0) or earlier.

Expand Down
49 changes: 15 additions & 34 deletions ReSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,6 @@
3F13C0E41E7B3E4000D8442C /* Sources */,
3F13C0E51E7B3E4000D8442C /* Frameworks */,
3F13C0E61E7B3E4000D8442C /* Resources */,
C6C5ED535A5FCEB5648419A2 /* [CP] Embed Pods Frameworks */,
3BED8D2D43A452D599C2F312 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -532,41 +530,50 @@
625E667A1C1FF97E0027C288 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Benjamin Encz";
TargetAttributes = {
25DBCF361C30BF2B00D63A58 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 1020;
};
25DBCF4D1C30C18D00D63A58 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 1020;
};
25DBCF631C30C1AC00D63A58 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 1020;
};
25DBCF7A1C30C4AA00D63A58 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 1020;
};
25DBCF861C30C4DB00D63A58 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 1020;
};
3F13C0E71E7B3E4000D8442C = {
CreatedOnToolsVersion = 8.2.1;
LastSwiftMigration = 1020;
};
625E66821C1FF97E0027C288 = {
CreatedOnToolsVersion = 7.1.1;
LastSwiftMigration = 1020;
};
625E66991C1FFA3C0027C288 = {
CreatedOnToolsVersion = 7.1.1;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = 625E667D1C1FF97E0027C288 /* Build configuration list for PBXProject "ReSwift" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 625E66791C1FF97E0027C288;
productRefGroup = 625E66841C1FF97E0027C288 /* Products */;
Expand Down Expand Up @@ -645,21 +652,6 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
3BED8D2D43A452D599C2F312 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwiftLintIntegration/Pods-SwiftLintIntegration-resources.sh\"\n";
showEnvVarsInLog = 0;
};
6012A4D4990919B303E1357A /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -706,21 +698,6 @@
shellPath = /bin/sh;
shellScript = "\"$SRCROOT/BuildPhases/run-swiftlint\"";
};
C6C5ED535A5FCEB5648419A2 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwiftLintIntegration/Pods-SwiftLintIntegration-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -962,6 +939,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "reswift.github.io.ReSwift-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3;
};
name = Debug;
};
Expand All @@ -974,6 +952,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = 3;
};
name = Release;
};
Expand Down Expand Up @@ -1072,6 +1051,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -1139,6 +1119,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
6 changes: 6 additions & 0 deletions ReSwift/CoreTypes/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,15 @@ open class Store<State: StateType>: StoreType {
}

open func unsubscribe(_ subscriber: AnyStoreSubscriber) {
#if swift(>=5.0)
if let index = subscriptions.firstIndex(where: { return $0.subscriber === subscriber }) {
subscriptions.remove(at: index)
}
#else
if let index = subscriptions.index(where: { return $0.subscriber === subscriber }) {
subscriptions.remove(at: index)
}
#endif
}

// swiftlint:disable:next identifier_name
Expand Down
22 changes: 19 additions & 3 deletions ReSwift/CoreTypes/Subscription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,25 @@ class SubscriptionBox<State>: Hashable {
weak var subscriber: AnyStoreSubscriber?
private let objectIdentifier: ObjectIdentifier

var hashValue: Int {
return self.objectIdentifier.hashValue
}
#if swift(>=5.0)
func hash(into hasher: inout Hasher) {
hasher.combine(self.objectIdentifier)
}
#elseif swift(>=4.2)
#if compiler(>=5.0)
func hash(into hasher: inout Hasher) {
hasher.combine(self.objectIdentifier)
}
#else
var hashValue: Int {
return self.objectIdentifier.hashValue
}
#endif
#else
var hashValue: Int {
return self.objectIdentifier.hashValue
}
#endif

init<T>(
originalSubscription: Subscription<State>,
Expand Down
2 changes: 1 addition & 1 deletion ReSwift/Utils/Assertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Foundation
- parameter line: Calling line
*/
func raiseFatalError(_ message: @autoclosure () -> String = "",
file: StaticString = #file, line: UInt = #line) -> Never {
file: StaticString = #file, line: UInt = #line) -> Never {
Assertions.fatalErrorClosure(message(), file, line)
repeat {
RunLoop.current.run()
Expand Down
8 changes: 4 additions & 4 deletions ReSwiftTests/XCTest+Assertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public extension XCTestCase {
- parameter testCase: The test case to be executed that expected to fire the assertion
method.
*/
public func expectFatalError(expectedMessage: String? = nil, file: StaticString = #file,
line: UInt = #line, testCase: @escaping () -> Void) {
func expectFatalError(expectedMessage: String? = nil, file: StaticString = #file,
line: UInt = #line, testCase: @escaping () -> Void) {
expectAssertionNoReturnFunction(
functionName: "fatalError",
file: file,
Expand All @@ -36,7 +36,7 @@ public extension XCTestCase {
},
expectedMessage: expectedMessage,
testCase: testCase,
cleanUp: {
cleanUp: {
Assertions.fatalErrorClosure = Assertions.swiftFatalErrorClosure
})
}
Expand All @@ -54,7 +54,7 @@ public extension XCTestCase {
cleanUp: @escaping () -> Void) {

let asyncExpectation = futureExpectation(withDescription: funcName + "-Expectation")
var assertionMessage: String? = nil
var assertionMessage: String?

function { (message) -> Void in
assertionMessage = message
Expand Down

0 comments on commit 83da0e5

Please sign in to comment.