From 2a7ff98e59d5e9658a4d387bbe454220399c3677 Mon Sep 17 00:00:00 2001 From: Marat Al Date: Tue, 19 Sep 2023 17:21:32 +0200 Subject: [PATCH] Cherry-pick pull request #1801 `git cherry-pick -m1 d8c8a7504a5346e96a4d0476829c2890614a72ee` Merge pull request #1801 from ably/fix/1764-preparation-for-macos-13 [SDK-3644] Preparation for macOS 13 --- Cartfile.private | 2 +- Cartfile.resolved | 2 +- Makefile | 4 ++-- Source/ARTRealtimePresence.m | 10 +--------- Spec/Test Utilities/TestUtilities.swift | 6 +++--- Spec/Tests/AuthTests.swift | 6 +++--- Spec/Tests/RealtimeClientChannelTests.swift | 10 +++++----- Spec/Tests/RealtimeClientPresenceTests.swift | 12 ++++++------ Spec/Tests/RealtimeClientTests.swift | 2 +- Spec/Tests/RestClientChannelsTests.swift | 2 +- Spec/Tests/RestClientPresenceTests.swift | 20 +++++++++----------- Spec/Tests/RestClientTests.swift | 4 ++-- 12 files changed, 35 insertions(+), 45 deletions(-) diff --git a/Cartfile.private b/Cartfile.private index baf8b7405..2c4874479 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1 +1 @@ -github "Quick/Nimble" == 9.2.1 \ No newline at end of file +github "Quick/Nimble" == 11.2.2 \ No newline at end of file diff --git a/Cartfile.resolved b/Cartfile.resolved index 7d5ae0308..0eff4ee92 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,3 @@ -github "Quick/Nimble" "v9.2.1" +github "Quick/Nimble" "v11.2.2" github "ably/delta-codec-cocoa" "1.3.3" github "rvi/msgpack-objective-C" "0.4.0" diff --git a/Makefile b/Makefile index 9fa5da42b..537299993 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ carthage_package: # https://github.com/Carthage/Carthage#archive-prebuilt-frameworks-into-one-zip-file # From `carthage help build` we are told that `--archive` implies `--no-skip-current`. - ./Scripts/carthage-with-workaround-for-issue-3019.sh build --archive --no-use-binaries + ./Scripts/carthage-with-workaround-for-issue-3019.sh build --archive --no-use-binaries --platform iOS,macOS,tvOS # Add LICENSE files (ours and SocketRocket’s). ./Scripts/add-licenses-to-carthage-output.sh @@ -105,7 +105,7 @@ carthage_clean: update_carthage_dependencies: $(info Updating Carthage dependencies for all platforms…) - carthage update --use-xcframeworks --no-use-binaries + carthage update --use-xcframeworks --platform iOS,macOS,tvOS --no-use-binaries ## [Carthage] Update dependencies for just iOS update_carthage_dependencies_ios: diff --git a/Source/ARTRealtimePresence.m b/Source/ARTRealtimePresence.m index 69ad27507..a9efe35eb 100644 --- a/Source/ARTRealtimePresence.m +++ b/Source/ARTRealtimePresence.m @@ -222,15 +222,7 @@ - (void)history:(ARTPaginatedPresenceCallback)callback { - (BOOL)history:(ARTRealtimeHistoryQuery *)query callback:(ARTPaginatedPresenceCallback)callback error:(NSError **)errorPtr { query.realtimeChannel = _channel; - @try { - return [_channel.restChannel.presence history:query callback:callback error:errorPtr]; - } - @catch (NSError *error) { - if (errorPtr) { - *errorPtr = error; - } - return false; - } + return [_channel.restChannel.presence history:query callback:callback error:errorPtr]; } - (void)enter:(id)data { diff --git a/Spec/Test Utilities/TestUtilities.swift b/Spec/Test Utilities/TestUtilities.swift index 03ab9e3f1..e5d3e3507 100644 --- a/Spec/Test Utilities/TestUtilities.swift +++ b/Spec/Test Utilities/TestUtilities.swift @@ -1698,7 +1698,7 @@ extension ARTPresenceAction : CustomStringConvertible { // MARK: - Custom Nimble Matchers /// A Nimble matcher that succeeds when two dates are quite the same. -public func beCloseTo(_ expectedValue: Date) -> Predicate { +public func beCloseTo(_ expectedValue: Date) -> Nimble.Predicate { let errorMessage = "be close to <\(expectedValue)> (within 0.5)" return Predicate.simple(errorMessage) { actualExpression in guard let actualValue = try actualExpression.evaluate() else { @@ -1712,7 +1712,7 @@ public func beCloseTo(_ expectedValue: Date) -> Predicate { } /// A Nimble matcher that succeeds when a param exists. -public func haveParam(_ key: String, withValue expectedValue: String? = nil) -> Predicate { +public func haveParam(_ key: String, withValue expectedValue: String? = nil) -> Nimble.Predicate { let errorMessage = "param <\(key)=\(expectedValue ?? "nil")> exists" return Predicate.simple(errorMessage) { actualExpression in guard let actualValue = try actualExpression.evaluate() else { @@ -1730,7 +1730,7 @@ public func haveParam(_ key: String, withValue expectedValue: String? = nil) -> } /// A Nimble matcher that succeeds when a param value starts with a particular string. -public func haveParam(_ key: String, hasPrefix expectedValue: String) -> Predicate { +public func haveParam(_ key: String, hasPrefix expectedValue: String) -> Nimble.Predicate { let errorMessage = "param <\(key)> has prefix \(expectedValue)" return Predicate.simple(errorMessage) { actualExpression in guard let actualValue = try actualExpression.evaluate() else { diff --git a/Spec/Tests/AuthTests.swift b/Spec/Tests/AuthTests.swift index 79bb2e9ca..6ecbcc54b 100644 --- a/Spec/Tests/AuthTests.swift +++ b/Spec/Tests/AuthTests.swift @@ -3671,9 +3671,9 @@ class AuthTests: XCTestCase { realtime.auth.authorize(callback) } - expect(didCancelAuthorization).to(be(true)) - expect(realtime.auth.tokenDetails).to(beIdenticalTo(tokenDetailsLast)) - expect(realtime.auth.tokenDetails?.token).to(equal(tokenDetailsLast?.token)) + XCTAssertTrue(didCancelAuthorization) + XCTAssertTrue(realtime.auth.tokenDetails === tokenDetailsLast) + XCTAssertEqual(realtime.auth.tokenDetails?.token, tokenDetailsLast?.token) if let transport = realtime.internal.transport as? TestProxyTransport, let query = transport.lastUrl?.query { expect(query).to(haveParam("accessToken", withValue: realtime.auth.tokenDetails?.token ?? "")) diff --git a/Spec/Tests/RealtimeClientChannelTests.swift b/Spec/Tests/RealtimeClientChannelTests.swift index 8539fe659..0baa66c43 100644 --- a/Spec/Tests/RealtimeClientChannelTests.swift +++ b/Spec/Tests/RealtimeClientChannelTests.swift @@ -219,13 +219,13 @@ class RealtimeClientChannelTests: XCTestCase { } expect(channel1.internal.presenceMap.members).toEventually(haveCount(2), timeout: testTimeout) - expect(channel1.internal.presenceMap.members.keys).to(allPass { $0!.hasPrefix("\(channel1.internal.connectionId):Client") || $0!.hasPrefix("\(channel2.internal.connectionId):Client") }) - expect(channel1.internal.presenceMap.members.values).to(allPass { $0!.action == .present }) + expect(channel1.internal.presenceMap.members.keys).to(allPass { $0.hasPrefix("\(channel1.internal.connectionId):Client") || $0.hasPrefix("\(channel2.internal.connectionId):Client") }) + expect(channel1.internal.presenceMap.members.values).to(allPass { $0.action == .present }) expect(channel2.internal.presenceMap.members).toEventually(haveCount(2), timeout: testTimeout) - expect(channel2.internal.presenceMap.members.keys).to(allPass { $0!.hasPrefix("\(channel1.internal.connectionId):Client") || $0!.hasPrefix("\(channel2.internal.connectionId):Client") }) - expect(channel2.internal.presenceMap.members["\(channel1.internal.connectionId):Client 1"]!.action).to(equal(ARTPresenceAction.present)) - expect(channel2.internal.presenceMap.members["\(channel2.internal.connectionId):Client 2"]!.action).to(equal(ARTPresenceAction.present)) + expect(channel2.internal.presenceMap.members.keys).to(allPass { $0.hasPrefix("\(channel1.internal.connectionId):Client") || $0.hasPrefix("\(channel2.internal.connectionId):Client") }) + XCTAssertEqual(channel2.internal.presenceMap.members["\(channel1.internal.connectionId):Client 1"]!.action, ARTPresenceAction.present) + XCTAssertEqual(channel2.internal.presenceMap.members["\(channel2.internal.connectionId):Client 2"]!.action, ARTPresenceAction.present) } // RTL2 diff --git a/Spec/Tests/RealtimeClientPresenceTests.swift b/Spec/Tests/RealtimeClientPresenceTests.swift index 64fb89855..ab11b13aa 100644 --- a/Spec/Tests/RealtimeClientPresenceTests.swift +++ b/Spec/Tests/RealtimeClientPresenceTests.swift @@ -3170,8 +3170,8 @@ class RealtimeClientPresenceTests: XCTestCase { expect(members).to(haveCount(150)) expect(members!.first).to(beAnInstanceOf(ARTPresenceMessage.self)) expect(members).to(allPass { member in - NSRegularExpression.match(member!.clientId, pattern: "^user(\\d+)$") - && (member!.data as? String) == expectedData + NSRegularExpression.match(member.clientId, pattern: "^user(\\d+)$") + && (member.data as? String) == expectedData }) done() } @@ -3664,8 +3664,8 @@ class RealtimeClientPresenceTests: XCTestCase { let members = membersPage.items expect(members).to(allPass { member in - NSRegularExpression.match(member!.clientId, pattern: expectedPattern) - && (member!.data as! [String]) == expectedData + NSRegularExpression.match(member.clientId, pattern: expectedPattern) + && (member.data as! [String]) == expectedData }) expect(membersPage.hasNext).to(beTrue()) @@ -3681,8 +3681,8 @@ class RealtimeClientPresenceTests: XCTestCase { let members = nextPage.items expect(members).to(allPass { member in - NSRegularExpression.match(member!.clientId, pattern: expectedPattern) - && (member!.data as! [String]) == expectedData + NSRegularExpression.match(member.clientId, pattern: expectedPattern) + && (member.data as! [String]) == expectedData }) expect(nextPage.hasNext).to(beFalse()) diff --git a/Spec/Tests/RealtimeClientTests.swift b/Spec/Tests/RealtimeClientTests.swift index b2bd73b9e..7bc20f1c2 100644 --- a/Spec/Tests/RealtimeClientTests.swift +++ b/Spec/Tests/RealtimeClientTests.swift @@ -221,7 +221,7 @@ class RealtimeClientTests: XCTestCase { /** Test that replacing query string default values in ARTClientOptions works properly */ - expect(absoluteString?.components(separatedBy: "v=").count).to(be(2)) + XCTAssertEqual(absoluteString.components(separatedBy: "v=").count, 2) done() } diff --git a/Spec/Tests/RestClientChannelsTests.swift b/Spec/Tests/RestClientChannelsTests.swift index 37af3d7c1..9bcd8bac5 100644 --- a/Spec/Tests/RestClientChannelsTests.swift +++ b/Spec/Tests/RestClientChannelsTests.swift @@ -9,7 +9,7 @@ extension ARTRestChannels: Sequence { } } -private func beAChannel(named expectedValue: String) -> Predicate { +private func beAChannel(named expectedValue: String) -> Nimble.Predicate { return Predicate.define("be a channel with name \"\(expectedValue)\"") { actualExpression, msg -> PredicateResult in let actualValue = try! actualExpression.evaluate() let m = msg.appended(details: "\"\(actualValue?.name ?? "nil")\" instead") diff --git a/Spec/Tests/RestClientPresenceTests.swift b/Spec/Tests/RestClientPresenceTests.swift index e1a5df4ae..babd8f5ba 100644 --- a/Spec/Tests/RestClientPresenceTests.swift +++ b/Spec/Tests/RestClientPresenceTests.swift @@ -36,8 +36,8 @@ class RestClientPresenceTests: XCTestCase { let members = membersPage.items expect(members).to(allPass { member in - NSRegularExpression.match(member!.clientId, pattern: expectedPattern) - && (member!.data as? String) == expectedData + NSRegularExpression.match(member.clientId, pattern: expectedPattern) + && (member.data as? String) == expectedData }) expect(membersPage.hasNext).to(beTrue()) @@ -51,8 +51,8 @@ class RestClientPresenceTests: XCTestCase { let members = nextPage.items expect(members).to(allPass { member in - NSRegularExpression.match(member!.clientId, pattern: expectedPattern) - && (member!.data as? String) == expectedData + NSRegularExpression.match(member.clientId, pattern: expectedPattern) + && (member.data as? String) == expectedData }) expect(nextPage.hasNext).to(beFalse()) @@ -147,7 +147,6 @@ class RestClientPresenceTests: XCTestCase { expect(membersPage!.hasNext).to(beFalse()) expect(membersPage!.isLast).to(beTrue()) expect(membersPage!.items).to(allPass { member in - let member = member! return NSRegularExpression.match(member.clientId, pattern: "^user(7|8|9)") }) done() @@ -184,8 +183,8 @@ class RestClientPresenceTests: XCTestCase { let members = membersPage.items expect(members).to(allPass { member in - NSRegularExpression.match(member!.clientId, pattern: expectedPattern) - && (member!.data as? String) == expectedData + NSRegularExpression.match(member.clientId, pattern: expectedPattern) + && (member.data as? String) == expectedData }) expect(membersPage.hasNext).to(beTrue()) @@ -201,8 +200,8 @@ class RestClientPresenceTests: XCTestCase { let members = nextPage.items expect(members).to(allPass { member in - NSRegularExpression.match(member!.clientId, pattern: expectedPattern) - && (member!.data as? String) == expectedData + NSRegularExpression.match(member.clientId, pattern: expectedPattern) + && (member.data as? String) == expectedData }) expect(nextPage.hasNext).to(beFalse()) @@ -342,8 +341,7 @@ class RestClientPresenceTests: XCTestCase { expect(membersPage!.hasNext).to(beFalse()) expect(membersPage!.isLast).to(beTrue()) expect(membersPage!.items).to(allPass { member in - let member = member - return NSRegularExpression.match(member!.clientId, pattern: "^user(7|8|9)") + return NSRegularExpression.match(member.clientId, pattern: "^user(7|8|9)") }) done() } diff --git a/Spec/Tests/RestClientTests.swift b/Spec/Tests/RestClientTests.swift index 09a639614..959e79040 100644 --- a/Spec/Tests/RestClientTests.swift +++ b/Spec/Tests/RestClientTests.swift @@ -1456,7 +1456,7 @@ class RestClientTests: XCTestCase { $0.allHTTPHeaderFields!["Host"] == $0.url?.host } - expect(fallbackRequests.count).to(be(fallbackRequestsWithHostHeader.count)) + XCTAssertEqual(fallbackRequests.count, fallbackRequestsWithHostHeader.count) afterEach__RestClient__Host_Fallback__retry_hosts_in_random_order() } @@ -2071,7 +2071,7 @@ class RestClientTests: XCTestCase { } expect(fallbackRequests).toNot(beEmpty()) - expect(fallbackRequests).to(allPass { extractURLQueryValue($0?.url, key: "request_id") == requestId }) + expect(fallbackRequests).to(allPass { extractURLQueryValue($0.url, key: "request_id") == requestId }) } func test__097__RestClient__request_IDs__ErrorInfo_should_have__requestId__property() {