Skip to content

Commit

Permalink
Migrate to Swift 5️⃣.4️⃣ (#245)
Browse files Browse the repository at this point in the history
Until recently, macOS 11 images were only available privately in GH
Actions, but apparently they can now be used by everyone (again). This
means that Xcode 12.5 and Swift 5.4 are now available.

## Changes

- Update `ci.yml` macOS image to `macOS-11`.

- Update `ci.yml` `DEVELOPER_DIR` to point to Xcode 12.5.

- Update podspec's `swift_version` to 5.4.

- Update `README.md`.

- Migrate `XCTAssert`'s that compared references via `===` to use the
new `XCTAssertIdentical` and `XCTAssertNotIdentical` XCTest APIs.
  • Loading branch information
p4checo authored Aug 6, 2021
1 parent 554a85c commit 23ebbba
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 40 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ on:

env:
# https://github.com/actions/virtual-environments/tree/main/images/macos
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_12.5.app/Contents/Developer

jobs:
env-details:
name: Environment details
runs-on: macOS-10.15
runs-on: macOS-11
steps:
- name: xcode version
run: xcodebuild -version -sdk
Expand All @@ -29,7 +29,7 @@ jobs:
build-test:
name: Build and Test
runs-on: macOS-10.15
runs-on: macos-11
env:
WORKSPACE: Alicerce.xcworkspace
SCHEME: Alicerce
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:

swiftpm:
name: SwiftPM Build
runs-on: macOS-10.15
runs-on: macOS-11
env:
PLATFORM_TARGET: x86_64-apple-ios14.0-simulator
steps:
Expand All @@ -75,7 +75,7 @@ jobs:

cocoapods:
name: CocoaPods Verification
runs-on: macOS-10.15
runs-on: macOS-11
steps:
- name: git checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:

carthage:
name: Carthage Verification
runs-on: macos-10.15
runs-on: macos-11
steps:
- name: git checkout
uses: actions/checkout@v2
Expand All @@ -114,7 +114,7 @@ jobs:

release-github:
name: GitHub Release
runs-on: macOS-10.15
runs-on: macOS-11
needs: [build-test, swiftpm, cocoapods, carthage]
if: startsWith(github.ref, 'refs/tags/')
steps:
Expand All @@ -133,7 +133,7 @@ jobs:
release-cocoapods:
name: CocoaPods Release
runs-on: macOS-10.15
runs-on: macOS-11
needs: [build-test, swiftpm, cocoapods, carthage]
if: startsWith(github.ref, 'refs/tags/')
steps:
Expand Down
2 changes: 1 addition & 1 deletion Alicerce.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/Mindera/Alicerce.git', :tag => "#{s.version}" }

s.module_name = 'Alicerce'
s.swift_version = '5.3'
s.swift_version = '5.4'

s.ios.deployment_target = '10.0'

Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/Mindera/Alicerce/blob/master/LICENSE)
[![release](https://img.shields.io/github/release/Mindera/Alicerce.svg)](https://github.com/Mindera/Alicerce/releases)
![platforms](https://img.shields.io/badge/platforms-iOS-lightgrey.svg)
[![Swift 5.3](https://img.shields.io/badge/Swift-5.3-orange.svg?style=flat)](https://developer.apple.com/swift/)
[![Swift 5.4](https://img.shields.io/badge/Swift-5.4-orange.svg?style=flat)](https://developer.apple.com/swift/)
[![Carthage](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![CocoaPods](https://img.shields.io/cocoapods/v/Alicerce.svg)](https://cocoapods.org/)
[![SwiftPM](https://img.shields.io/badge/SwiftPM-compatible-orange.svg)](#swift-package-manager)
Expand Down Expand Up @@ -50,10 +50,16 @@ TODO

## Compatibility ✅

### `0.11.0` ... `master`
### `master`

- iOS 10.0+
- Xcode 12
- Xcode 12.5
- Swift 5.4

### `0.11.0` ... `0.12.0` (latest)

- iOS 10.0+
- Xcode 12.4
- Swift 5.3

### `0.9.0` ... `0.10.0`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ final class NSLayoutConstraintTestCase: XCTestCase {

func testWithPriority_WithAnyValue_ShouldReturnItself() {

XCTAssert(constraint.with(priority: .defaultHigh) === constraint)
XCTAssert(constraint.with(priority: .init(666)) === constraint)
XCTAssertIdentical(constraint.with(priority: .defaultHigh), constraint)
XCTAssertIdentical(constraint.with(priority: .init(666)), constraint)
}

// MARK: - Activation
Expand All @@ -86,7 +86,7 @@ final class NSLayoutConstraintTestCase: XCTestCase {

func testSetActive_WithAnyValue_ShouldReturnItself() {

XCTAssert(constraint.set(active: false) === constraint)
XCTAssert(constraint.set(active: true) === constraint)
XCTAssertIdentical(constraint.set(active: false), constraint)
XCTAssertIdentical(constraint.set(active: true), constraint)
}
}
8 changes: 4 additions & 4 deletions Tests/AlicerceTests/AutoLayout/XCTAssertConstraint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ func XCTAssertConstraint(
XCTAssertFalse(item.translatesAutoresizingMaskIntoConstraints, file: file, line: line)
}

XCTAssert(constraint1.firstItem === constraint2.firstItem, file: file, line: line)
XCTAssertIdentical(constraint1.firstItem, constraint2.firstItem, file: file, line: line)
XCTAssertEqual(constraint1.firstAttribute, constraint2.firstAttribute, file: file, line: line)

XCTAssert(constraint1.secondItem === constraint2.secondItem, file: file, line: line)
XCTAssertIdentical(constraint1.secondItem, constraint2.secondItem, file: file, line: line)
XCTAssertEqual(constraint1.secondAttribute, constraint2.secondAttribute, file: file, line: line)

XCTAssertEqual(constraint1.relation, constraint2.relation, file: file, line: line)
Expand All @@ -39,10 +39,10 @@ func XCTAssertConstraints(
XCTAssertFalse(item.translatesAutoresizingMaskIntoConstraints, file: file, line: line)
}

XCTAssert(constraint1.firstItem === constraint2.firstItem, file: file, line: line)
XCTAssertIdentical(constraint1.firstItem, constraint2.firstItem, file: file, line: line)
XCTAssertEqual(constraint1.firstAttribute, constraint2.firstAttribute, file: file, line: line)

XCTAssert(constraint1.secondItem === constraint2.secondItem, file: file, line: line)
XCTAssertIdentical(constraint1.secondItem, constraint2.secondItem, file: file, line: line)
XCTAssertEqual(constraint1.secondAttribute, constraint2.secondAttribute, file: file, line: line)

XCTAssertEqual(constraint1.relation, constraint2.relation, file: file, line: line)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ class Route_TrieRouter_RouteTests: XCTestCase {
var handler = TestHandler()
handler.didHandle = { _route, _, _ in

XCTAssert(route === _route)
XCTAssertIdentical(route, _route)
handleExpectation.fulfill()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,6 @@ private extension Route_TrieRouter_UnregisterTests {
let registerRoute = initialRoute?.url(file: file, line: line) ?? _route

XCTAssertNoThrow(try router.register(registerRoute, handler: testHandler), file: file, line: line)
XCTAssert(try router.unregister(_route) === testHandler, file: file, line: line)
XCTAssertIdentical(try router.unregister(_route), testHandler, file: file, line: line)
}
}
6 changes: 3 additions & 3 deletions Tests/AlicerceTests/Logging/Loggers/MultiLoggerTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class MultiLoggerTestCase: XCTestCase {

let onError: MultiLogger.LogDestinationErrorClosure = { errorDestination, error in
defer { errorExpectation.fulfill() }
XCTAssert((errorDestination as? AnyMetadataLogDestination<MockMetadataKey>)?._wrapped === destination)
XCTAssertIdentical((errorDestination as? AnyMetadataLogDestination<MockMetadataKey>)?._wrapped, destination)
guard case MockError.😱 = error else { return XCTFail("unexpected error \(error)") }
}

Expand Down Expand Up @@ -249,7 +249,7 @@ class MultiLoggerTestCase: XCTestCase {

let onError: MultiLogger.LogDestinationErrorClosure = { errorDestination, error in
defer { errorExpectation.fulfill() }
XCTAssert((errorDestination as? AnyMetadataLogDestination<MockMetadataKey>)?._wrapped === destination)
XCTAssertIdentical((errorDestination as? AnyMetadataLogDestination<MockMetadataKey>)?._wrapped, destination)
guard case MockError.😱 = error else { return XCTFail("unexpected error \(error)") }
}

Expand Down Expand Up @@ -307,7 +307,7 @@ class MultiLoggerTestCase: XCTestCase {

let onError: MultiLogger.LogDestinationErrorClosure = { errorDestination, error in
defer { errorExpectation.fulfill() }
XCTAssert((errorDestination as? AnyMetadataLogDestination<MockMetadataKey>)?._wrapped === destination)
XCTAssertIdentical((errorDestination as? AnyMetadataLogDestination<MockMetadataKey>)?._wrapped, destination)
guard case MockError.😱 = error else { return XCTFail("unexpected error \(error)") }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Network_BaseRequestMakingTestCase: XCTestCase {
return mockCancelable
}

XCTAssert(cancelable === mockCancelable)
XCTAssertIdentical(cancelable, mockCancelable)
}

func testEndpoint_WithFailureEndpointMakeRequest_ShouldReturnFailure() {
Expand All @@ -48,6 +48,6 @@ class Network_BaseRequestMakingTestCase: XCTestCase {
return mockCancelable
}

XCTAssert(cancelable === mockCancelable)
XCTAssertIdentical(cancelable, mockCancelable)
}
}
2 changes: 1 addition & 1 deletion Tests/AlicerceTests/Network/NetworkTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class NetworkTestCase: XCTestCase {
let mappedValue = value.mapValue { v, r in String(v) }

XCTAssertEqual(mappedValue.value, "1337")
XCTAssert(mappedValue.response === response)
XCTAssertIdentical(mappedValue.response, response)
}

func testMapValue_WithFailureMap_ShouldThrow() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ final class URLSessionNetworkStackTestCase: XCTestCase {
let testAuthenticationChallengeHandler = MockAuthenticationChallengeHandler()
testAuthenticationChallengeHandler.mockHandleClosure = { challenge in
defer { expectation1.fulfill() }
XCTAssert(challenge === testAuthenticationChallenge)
XCTAssertIdentical(challenge, testAuthenticationChallenge)

return (testAuthDisposition, testCredential)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class URLSessionResourceInterceptorTestCase: XCTestCase {
return mockCancelable
}

XCTAssert(cancelable === mockCancelable)
XCTAssertIdentical(cancelable, mockCancelable)
}

func testDefaultInterceptMakeRequestResult_WithFailureResult_ShouldInvokeHandlerAndPropagateResult() {
Expand All @@ -32,7 +32,7 @@ class URLSessionResourceInterceptorTestCase: XCTestCase {
return mockCancelable
}

XCTAssert(cancelable === mockCancelable)
XCTAssertIdentical(cancelable, mockCancelable)
}

func testDefaultInterceptFailedTask_ShouldReturnNoneAction() {
Expand Down Expand Up @@ -71,7 +71,7 @@ class URLSessionResourceInterceptorTestCase: XCTestCase {
return mockCancelable
}

XCTAssert(cancelable === mockCancelable)
XCTAssertIdentical(cancelable, mockCancelable)
}

func testAuthenticatorInterceptMakeRequestResult_WithFailureResult_ShouldInvokeHandlerAndPropagateResult() {
Expand All @@ -86,7 +86,7 @@ class URLSessionResourceInterceptorTestCase: XCTestCase {
return mockCancelable
}

XCTAssert(cancelable === mockCancelable)
XCTAssertIdentical(cancelable, mockCancelable)
}

func testAuthenticatorInterceptFailedTask_ShouldReturnAuthenticatorAction() {
Expand Down
14 changes: 7 additions & 7 deletions Tests/AlicerceTests/Utils/BuilderCacheTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,39 +78,39 @@ class BuilderCacheTestCase: XCTestCase {
let dateFormatter1 = cache.object(SimpleDateFormatterKey("yyyy-MM-dd'T'HH:mm:ssZ"))
let dateFormatter2 = cache.object(SimpleDateFormatterKey("yyyy-MM-dd'T'HH:mm:ssZ"))

XCTAssertTrue(dateFormatter1 === dateFormatter2)
XCTAssertIdentical(dateFormatter1, dateFormatter2)
}

func testCache_WithSameComplexKey_ShouldReturnSameObject() {

let dateFormatter1 = cache.object(ComplexDateFormatterKey.utc(dateFormat: "yyyy-MM-dd'T'HH:mm:ssZ"))
let dateFormatter2 = cache.object(ComplexDateFormatterKey.utc(dateFormat: "yyyy-MM-dd'T'HH:mm:ssZ"))

XCTAssertTrue(dateFormatter1 === dateFormatter2)
XCTAssertIdentical(dateFormatter1, dateFormatter2)
}

func testCache_WithDifferentSimpleKeys_ShouldReturnDifferentObjects() {

let dateFormatter1 = cache.object(SimpleDateFormatterKey("yyyy-MM-dd'T'HH:mm:ssZ"))
let dateFormatter2 = cache.object(SimpleDateFormatterKey("yyyy-MM-dd'T'HH:mm:ss"))

XCTAssertFalse(dateFormatter1 === dateFormatter2)
XCTAssertNotIdentical(dateFormatter1, dateFormatter2)
}

func testCache_WithDifferentComplexKey_ShouldReturnDifferentObjects() {

let dateFormatter1 = cache.object(ComplexDateFormatterKey.utc(dateFormat: "yyyy-MM-dd'T'HH:mm:ssZ"))
let dateFormatter2 = cache.object(ComplexDateFormatterKey.local(dateFormat: "yyyy-MM-dd'T'HH:mm:ssZ"))

XCTAssertFalse(dateFormatter1 === dateFormatter2)
XCTAssertNotIdentical(dateFormatter1, dateFormatter2)
}

func testCache_WithDifferentKeyTypes_ShouldReturnDifferentObjects() {

let dateFormatter1 = cache.object(SimpleDateFormatterKey("yyyy-MM-dd'T'HH:mm:ssZ"))
let dateFormatter2 = cache.object(ComplexDateFormatterKey.utc(dateFormat: "yyyy-MM-dd'T'HH:mm:ssZ"))

XCTAssertFalse(dateFormatter1 === dateFormatter2)
XCTAssertNotIdentical(dateFormatter1, dateFormatter2)
}

func testCache_WithEvict_ShouldGenerateNewObject() {
Expand All @@ -119,7 +119,7 @@ class BuilderCacheTestCase: XCTestCase {
cache.evict(SimpleDateFormatterKey("yyyy-MM-dd'T'HH:mm:ssZ"))
let dateFormatter2 = cache.object(SimpleDateFormatterKey("yyyy-MM-dd'T'HH:mm:ssZ"))

XCTAssertFalse(dateFormatter1 === dateFormatter2)
XCTAssertNotIdentical(dateFormatter1, dateFormatter2)
}


Expand All @@ -129,6 +129,6 @@ class BuilderCacheTestCase: XCTestCase {
cache.evictAll()
let dateFormatter2 = cache.object(SimpleDateFormatterKey("yyyy-MM-dd'T'HH:mm:ssZ"))

XCTAssertFalse(dateFormatter1 === dateFormatter2)
XCTAssertNotIdentical(dateFormatter1, dateFormatter2)
}
}

0 comments on commit 23ebbba

Please sign in to comment.