From 9d0ceb915ae48b5fbb5fa42bd498f5330f95344a Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Fri, 19 Jan 2018 14:51:32 +0100 Subject: [PATCH 01/16] Update cocoapods version --- Podfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Podfile.lock b/Podfile.lock index 4a24f2293..59c37fe39 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -18,4 +18,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 7dc8141f83a4fb2abc77efcba70e9d8aee44d85e -COCOAPODS: 1.3.1 +COCOAPODS: 1.4.0 From 860c5b35ecbb7629b0f1b17f6b3636740ea5047d Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Fri, 19 Jan 2018 14:51:47 +0100 Subject: [PATCH 02/16] Update project settings --- Ably.xcodeproj/project.pbxproj | 14 +++++++++++++- .../xcshareddata/xcschemes/Ably.xcscheme | 4 +++- .../xcshareddata/xcschemes/AblySpec.xcscheme | 4 +++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Ably.xcodeproj/project.pbxproj b/Ably.xcodeproj/project.pbxproj index 76f410c63..68339ba69 100644 --- a/Ably.xcodeproj/project.pbxproj +++ b/Ably.xcodeproj/project.pbxproj @@ -913,7 +913,7 @@ attributes = { CLASSPREFIX = ART; LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0830; + LastUpgradeCheck = 0920; ORGANIZATIONNAME = Ably; TargetAttributes = { 856AAC891B6E304B00B07119 = { @@ -1190,14 +1190,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -1239,14 +1245,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; diff --git a/Ably.xcodeproj/xcshareddata/xcschemes/Ably.xcscheme b/Ably.xcodeproj/xcshareddata/xcschemes/Ably.xcscheme index f43b594b3..4fa6301c3 100644 --- a/Ably.xcodeproj/xcshareddata/xcschemes/Ably.xcscheme +++ b/Ably.xcodeproj/xcshareddata/xcschemes/Ably.xcscheme @@ -1,6 +1,6 @@ Date: Fri, 19 Jan 2018 14:54:03 +0100 Subject: [PATCH 03/16] Update project to Swift 4 --- Ably.xcodeproj/project.pbxproj | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Ably.xcodeproj/project.pbxproj b/Ably.xcodeproj/project.pbxproj index 68339ba69..c4a52dd28 100644 --- a/Ably.xcodeproj/project.pbxproj +++ b/Ably.xcodeproj/project.pbxproj @@ -918,10 +918,11 @@ TargetAttributes = { 856AAC891B6E304B00B07119 = { CreatedOnToolsVersion = 7.0; - LastSwiftMigration = 0820; + LastSwiftMigration = 0920; }; 96BF61301A35B2AB004CF2B3 = { CreatedOnToolsVersion = 6.1.1; + LastSwiftMigration = 0920; }; }; }; @@ -1156,7 +1157,8 @@ PRODUCT_NAME = AblySpec; SWIFT_OBJC_BRIDGING_HEADER = "Spec/AblySpec-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1178,7 +1180,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "io.ably.$(PRODUCT_NAME)"; PRODUCT_NAME = AblySpec; SWIFT_OBJC_BRIDGING_HEADER = "Spec/AblySpec-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -1306,7 +1309,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "io.ably.$(PRODUCT_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1329,7 +1333,8 @@ MODULEMAP_FILE = Source/Ably.modulemap; PRODUCT_BUNDLE_IDENTIFIER = "io.ably.$(PRODUCT_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; From 36fd0ad0c535b33bd3b2ea4e5258c03743572498 Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Fri, 19 Jan 2018 14:57:59 +0100 Subject: [PATCH 04/16] Update Nimble and Quick --- Podfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Podfile b/Podfile index b7aed776d..75e15c1ed 100644 --- a/Podfile +++ b/Podfile @@ -2,8 +2,8 @@ platform :ios, '8.0' use_frameworks! def test_pods - pod 'Quick', '1.1.0' - pod 'Nimble', '7.0.0' + pod 'Quick', '1.2.0' + pod 'Nimble', '7.0.3' # Helpers pod 'Aspects' pod 'SwiftyJSON', '3.1.4' From 7f8e59e4b8aa978fdc216f63a5f158fce6d8c05c Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Fri, 19 Jan 2018 15:02:35 +0100 Subject: [PATCH 05/16] New lock file --- Podfile.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 59c37fe39..883089e6e 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,21 +1,21 @@ PODS: - Aspects (1.4.1) - - Nimble (7.0.0) - - Quick (1.1.0) + - Nimble (7.0.3) + - Quick (1.2.0) - SwiftyJSON (3.1.4) DEPENDENCIES: - Aspects - - Nimble (= 7.0.0) - - Quick (= 1.1.0) + - Nimble (= 7.0.3) + - Quick (= 1.2.0) - SwiftyJSON (= 3.1.4) SPEC CHECKSUMS: Aspects: 7595ba96a6727a58ebcbfc954497fc5d2fdde546 - Nimble: 874982b605d4d752fcac6be695d13c502de84b1b - Quick: dafc587e21eed9f4cab3249b9f9015b0b7a7f71d + Nimble: 7f5a9c447a33002645a071bddafbfb24ea70e0ac + Quick: 58d203b1c5e27fff7229c4c1ae445ad7069a7a08 SwiftyJSON: c2842d878f95482ffceec5709abc3d05680c0220 -PODFILE CHECKSUM: 7dc8141f83a4fb2abc77efcba70e9d8aee44d85e +PODFILE CHECKSUM: bbc911685e19e03e4fc0bed9375d6679936a44f8 COCOAPODS: 1.4.0 From c479cd9f59da85e76261d00cf10b445837eeb778 Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Fri, 19 Jan 2018 15:02:52 +0100 Subject: [PATCH 06/16] New xcode in travis config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 650efb11b..18ee29e4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode8.3 +osx_image: xcode9.2 env: global: - LC_CTYPE=en_US.UTF-8 From 76f1ae7ec4726ff6efb100bfe1b7e4172caee92b Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Mon, 22 Jan 2018 14:35:05 +0100 Subject: [PATCH 07/16] Update fastlane version --- Scripts/setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/setup.sh b/Scripts/setup.sh index 33d0e350d..b09a356e3 100755 --- a/Scripts/setup.sh +++ b/Scripts/setup.sh @@ -4,7 +4,7 @@ set -e # Install Fastlane -gem install fastlane +gem install fastlane -v 2.77.1 # Install CocoaPods gem install cocoapods @@ -14,4 +14,4 @@ brew update && brew install carthage # Install dependencies pod install -carthage bootstrap \ No newline at end of file +carthage bootstrap From 2e883104b7ca4927e4ca28f6d76ebf4ef014616e Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Fri, 26 Jan 2018 18:51:01 +0100 Subject: [PATCH 08/16] Fix Syntax errors --- Spec/Auth.swift | 2 +- Spec/RealtimeClient.swift | 2 +- Spec/RealtimeClientConnection.swift | 6 +++--- Spec/RestClient.swift | 6 +++--- Spec/RestClientChannel.swift | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Spec/Auth.swift b/Spec/Auth.swift index fc084d9a3..456ab7649 100644 --- a/Spec/Auth.swift +++ b/Spec/Auth.swift @@ -256,7 +256,7 @@ class Auth : QuickSpec { let channel = rest.channels.get("test") - testHTTPExecutor.afterRequest = { _ in + testHTTPExecutor.afterRequest = { _ , _ in testHTTPExecutor.simulateIncomingServerErrorOnNextRequest(40141, description: "token revoked") } diff --git a/Spec/RealtimeClient.swift b/Spec/RealtimeClient.swift index 4d229f4ae..caa33077f 100644 --- a/Spec/RealtimeClient.swift +++ b/Spec/RealtimeClient.swift @@ -1231,7 +1231,7 @@ class RealtimeClient: QuickSpec { // https://github.com/ably/ably-ios/issues/577 it("background behaviour") { waitUntil(timeout: testTimeout) { done in - URLSession.shared.dataTask(with: NSURL(string:"https://ably.io")! as URL) { _ in + URLSession.shared.dataTask(with: NSURL(string:"https://ably.io")! as URL) { _ , _ , _ in let realtime = ARTRealtime(options: AblyTests.commonAppSetup()) realtime.channels.get("foo").attach { error in expect(error).to(beNil()) diff --git a/Spec/RealtimeClientConnection.swift b/Spec/RealtimeClientConnection.swift index e352e021e..6cf83beb0 100644 --- a/Spec/RealtimeClientConnection.swift +++ b/Spec/RealtimeClientConnection.swift @@ -2125,7 +2125,7 @@ class RealtimeClientConnection: QuickSpec { options.autoConnect = false let expectedTime: TimeInterval = 1.0 - options.authCallback = { _ in + options.authCallback = { _ , _ in // Force a timeout } @@ -2162,7 +2162,7 @@ class RealtimeClientConnection: QuickSpec { options.autoConnect = false let expectedTime: TimeInterval = 1.0 - options.authCallback = { _ in + options.authCallback = { _ , _ in // Force a timeout } @@ -3502,7 +3502,7 @@ class RealtimeClientConnection: QuickSpec { expect(NSRegularExpression.match(urlConnections[1].absoluteString, pattern: "//[a-e].ably-realtime.com")).to(beTrue()) waitUntil(timeout: testTimeout) { done in - client.time { _ in + client.time { _ , _ in done() } } diff --git a/Spec/RestClient.swift b/Spec/RestClient.swift index 1bcb8d468..efc8f7977 100644 --- a/Spec/RestClient.swift +++ b/Spec/RestClient.swift @@ -1176,7 +1176,7 @@ class RestClient: QuickSpec { testHTTPExecutor.http = MockHTTP(network: .host400BadRequest) let channel = client.channels.get("test") - testHTTPExecutor.afterRequest = { _ in + testHTTPExecutor.afterRequest = { _ , _ in if testHTTPExecutor.requests.count == 2 { // Stop testHTTPExecutor.http = nil @@ -1321,9 +1321,9 @@ class RestClient: QuickSpec { it("background behaviour") { let options = AblyTests.commonAppSetup() waitUntil(timeout: testTimeout) { done in - URLSession.shared.dataTask(with: NSURL(string:"https://ably.io")! as URL) { _ in + URLSession.shared.dataTask(with: NSURL(string:"https://ably.io")! as URL) { _ , _ , _ in let rest = ARTRest(options: options) - rest.channels.get("foo").history { _ in + rest.channels.get("foo").history { _ , _ in done() } }.resume() diff --git a/Spec/RestClientChannel.swift b/Spec/RestClientChannel.swift index 02ac2f83f..8bb7dbdbd 100644 --- a/Spec/RestClientChannel.swift +++ b/Spec/RestClientChannel.swift @@ -613,10 +613,10 @@ class RestClientChannel: QuickSpec { expect(query.limit) == 100 query.limit = 1001 - expect{ try channel.history(query, callback: { _ in }) }.to(throwError()) + expect{ try channel.history(query, callback: { _ , _ in }) }.to(throwError()) query.limit = 1000 - expect{ try channel.history(query, callback: { _ in }) }.toNot(throwError()) + expect{ try channel.history(query, callback: { _ , _ in }) }.toNot(throwError()) } } From 0b20dfb7260ca1f32f5c1bce42b65737dabf0457 Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Fri, 26 Jan 2018 18:51:13 +0100 Subject: [PATCH 09/16] Update name method --- Spec/TestUtilities.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spec/TestUtilities.swift b/Spec/TestUtilities.swift index a2c889166..e39d3ec4f 100644 --- a/Spec/TestUtilities.swift +++ b/Spec/TestUtilities.swift @@ -998,7 +998,7 @@ extension NSRegularExpression { let regex = try! NSRegularExpression(pattern: pattern, options: options) let range = NSMakeRange(0, value.lengthOfBytes(using: String.Encoding.utf8)) let result = regex.firstMatch(in: value, options: [], range: range) - guard let textRange = result?.rangeAt(0) else { return nil } + guard let textRange = result?.range(at: 0) else { return nil } let convertedRange = value.characters.index(value.startIndex, offsetBy: textRange.location).. Date: Fri, 26 Jan 2018 18:59:10 +0100 Subject: [PATCH 10/16] Rename to new class --- Spec/TestUtilities.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Spec/TestUtilities.swift b/Spec/TestUtilities.swift index e39d3ec4f..caa877510 100644 --- a/Spec/TestUtilities.swift +++ b/Spec/TestUtilities.swift @@ -1164,7 +1164,7 @@ public func haveParam(_ key: String, withValue expectedValue: String) -> Predica /// A Nimble matcher that succeeds when all Keys from a Dictionary are valid. public func allKeysPass (_ passFunc: @escaping (U.Key) -> Bool) -> Predicate where U: ExpressibleByDictionaryLiteral, U.Iterator.Element == (U.Key, U.Value) { - let elementEvaluator: (Expression, FailureMessage) throws -> Bool = { + let elementEvaluator: (Expression, FailureMessage) throws -> Bool = { expression, failureMessage in failureMessage.postfixMessage = "pass a condition" let value = try expression.evaluate()! @@ -1197,7 +1197,7 @@ public func allKeysPass (_ passFunc: @escaping (U.Key) -> Bool) - /// A Nimble matcher that succeeds when all Values from a Dictionary are valid. public func allValuesPass (_ passFunc: @escaping (U.Value) -> Bool) -> Predicate where U: ExpressibleByDictionaryLiteral, U.Iterator.Element == (U.Key, U.Value) { - let elementEvaluator: (Expression, FailureMessage) throws -> Bool = { + let elementEvaluator: (Expression, FailureMessage) throws -> Bool = { expression, failureMessage in failureMessage.postfixMessage = "pass a condition" let value = try expression.evaluate()! From 5380df63ff050e10275baa29aac4b0a605a817a7 Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Mon, 29 Jan 2018 11:18:44 +0100 Subject: [PATCH 11/16] Update Swift version --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 9f55b2ccb..5186d0706 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0 +4.0 From 21ec2ad0ac4a9cfba68e2a52c3a1687aa03ca03d Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Mon, 29 Jan 2018 12:31:24 +0100 Subject: [PATCH 12/16] Simplify test Compilation was failing due to this: https://travis-ci.org/ably/ably-ios/builds/334047803 --- Spec/RealtimeClientPresence.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Spec/RealtimeClientPresence.swift b/Spec/RealtimeClientPresence.swift index 4467381d2..7103dcfcf 100644 --- a/Spec/RealtimeClientPresence.swift +++ b/Spec/RealtimeClientPresence.swift @@ -846,7 +846,7 @@ class RealtimeClientPresence: QuickSpec { var clientMembers: ARTRealtime? waitUntil(timeout: testTimeout) { done in - clientMembers = AblyTests.addMembersSequentiallyToChannel("foo", members: 3, options: options) { + clientMembers = AblyTests.addMembersSequentiallyToChannel("foo", members: 2, options: options) { done() } } @@ -861,7 +861,7 @@ class RealtimeClientPresence: QuickSpec { let partialDone = AblyTests.splitDone(2, done: done) channel.presence.get { members, error in expect(error).to(beNil()) - expect(members).to(haveCount(3)) + expect(members).to(haveCount(2)) partialDone() } channel.presence.enter(nil) { error in @@ -870,7 +870,7 @@ class RealtimeClientPresence: QuickSpec { } } - expect(channel.presenceMap.members).to(haveCount(4)) + expect(channel.presenceMap.members).to(haveCount(3)) expect(channel.presenceMap.localMembers).to(haveCount(1)) waitUntil(timeout: testTimeout) { done in @@ -899,7 +899,7 @@ class RealtimeClientPresence: QuickSpec { channel.presence.subscribe(.leave) { leave in // Members will leave the PresenceMap due to the ATTACHED without Presence - expect(leave.clientId).to(satisfyAnyOf(equal("local1"), equal("user1"), equal("user2"), equal("user3"))) + expect(leave.clientId).to(satisfyAnyOf(equal("local1"), equal("user1"), equal("user2"))) } // Re-entered automatically From 98f45f3211ffc1cca4645ffaf3b8f5170a979ce7 Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Mon, 29 Jan 2018 14:17:22 +0100 Subject: [PATCH 13/16] Add project indentation settings --- Ably.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Ably.xcodeproj/project.pbxproj b/Ably.xcodeproj/project.pbxproj index c4a52dd28..6bbd98e76 100644 --- a/Ably.xcodeproj/project.pbxproj +++ b/Ably.xcodeproj/project.pbxproj @@ -517,7 +517,9 @@ FAFEC5BB8312EB69E84C28D4 /* Frameworks */, 514B60993BD8A01B13ECB1BC /* Pods */, ); + indentWidth = 4; sourceTree = ""; + tabWidth = 4; }; 96BF61321A35B2AB004CF2B3 /* Products */ = { isa = PBXGroup; From d569426f5c77fb596c14b8b252ca09dcbbd267eb Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Tue, 30 Jan 2018 09:30:46 +0100 Subject: [PATCH 14/16] Fix Swfit 4 warnings --- Spec/Auth.swift | 10 +++++----- Spec/RealtimeClientChannel.swift | 2 +- Spec/RealtimeClientConnection.swift | 2 +- Spec/RestClient.swift | 4 ++-- Spec/RestClientChannels.swift | 2 +- Spec/TestUtilities.swift | 14 +++++++------- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Spec/Auth.swift b/Spec/Auth.swift index 456ab7649..508bb3198 100644 --- a/Spec/Auth.swift +++ b/Spec/Auth.swift @@ -306,7 +306,7 @@ class Auth : QuickSpec { let options = AblyTests.commonAppSetup() options.authCallback = { tokenParams, completion in getTestToken() { token in - let invalidToken = String(token.characters.reversed()) + let invalidToken = String(token.reversed()) completion(invalidToken as ARTTokenDetailsCompatible?, nil) } } @@ -558,7 +558,7 @@ class Auth : QuickSpec { } // Token should renew and fail - let invalidToken = String(token.characters.reversed()) + let invalidToken = String(token.reversed()) AblyTests.queue.sync { realtime.options.authParams = [NSURLQueryItem]() as [URLQueryItem]? realtime.options.authParams?.append(NSURLQueryItem(name: "type", value: "json") as URLQueryItem) @@ -1986,7 +1986,7 @@ class Auth : QuickSpec { guard let tokenRequest1 = tokenRequest else { XCTFail("TokenRequest1 is nil"); done(); return } - expect(tokenRequest1.nonce.characters).to(haveCount(16)) + expect(tokenRequest1.nonce).to(haveCount(16)) // Second rest.auth.createTokenRequest(nil, options: nil, callback: { tokenRequest, error in @@ -1994,7 +1994,7 @@ class Auth : QuickSpec { guard let tokenRequest2 = tokenRequest else { XCTFail("TokenRequest2 is nil"); done(); return } - expect(tokenRequest2.nonce.characters).to(haveCount(16)) + expect(tokenRequest2.nonce).to(haveCount(16)) // Uniqueness expect(tokenRequest1.nonce).toNot(equal(tokenRequest2.nonce)) @@ -2226,7 +2226,7 @@ class Auth : QuickSpec { } expect(tokenRequest.clientId).to(equal(expectedClientId)) expect(tokenRequest.mac).toNot(beNil()) - expect(tokenRequest.nonce.characters).to(haveCount(16)) + expect(tokenRequest.nonce).to(haveCount(16)) expect(tokenRequest.ttl as? TimeInterval).to(equal(expectedTtl)) expect(tokenRequest.capability).to(equal(expectedCapability)) expect(tokenRequest.timestamp).to(beCloseTo(serverTime!, within: 6.0)) diff --git a/Spec/RealtimeClientChannel.swift b/Spec/RealtimeClientChannel.swift index bdde222b6..b90069211 100644 --- a/Spec/RealtimeClientChannel.swift +++ b/Spec/RealtimeClientChannel.swift @@ -2623,7 +2623,7 @@ class RealtimeClientChannel: QuickSpec { if protocolMessage.action == .message { let messageReceived = protocolMessage.messages![0] // Replacement: `json/utf-8/cipher+aes-256-cbc/base64` to `invalid/cipher+aes-256-cbc/base64` - let newEncoding = "invalid" + messageReceived.encoding!.substring(from: "json/utf-8".endIndex) + let newEncoding = "invalid" + messageReceived.encoding!["json/utf-8".endIndex...] messageReceived.encoding = newEncoding } } diff --git a/Spec/RealtimeClientConnection.swift b/Spec/RealtimeClientConnection.swift index 6cf83beb0..571300b12 100644 --- a/Spec/RealtimeClientConnection.swift +++ b/Spec/RealtimeClientConnection.swift @@ -1859,7 +1859,7 @@ class RealtimeClientConnection: QuickSpec { // RTN14a it("should enter FAILED state when API key is invalid") { let options = AblyTests.commonAppSetup() - options.key = String(options.key!.characters.reversed()) + options.key = String(options.key!.reversed()) options.autoConnect = false let client = ARTRealtime(options: options) defer { diff --git a/Spec/RestClient.swift b/Spec/RestClient.swift index efc8f7977..ee0d51346 100644 --- a/Spec/RestClient.swift +++ b/Spec/RestClient.swift @@ -535,7 +535,7 @@ class RestClient: QuickSpec { waitUntil(timeout: testTimeout) { done in // Delay for token expiration - delay(TimeInterval(tokenParams.ttl!)) { + delay(TimeInterval(truncating: tokenParams.ttl!)) { // [40140, 40150) - token expired and will not recover because authUrl is invalid publishTestMessage(rest) { error in guard let errorCode = testHTTPExecutor.responses.first?.allHeaderFields["X-Ably-Errorcode"] as? String else { @@ -583,7 +583,7 @@ class RestClient: QuickSpec { rest.httpExecutor = testHTTPExecutor // Delay for token expiration - delay(TimeInterval(tokenParams.ttl!)) { + delay(TimeInterval(truncating: tokenParams.ttl!)) { // [40140, 40150) - token expired and will not recover because authUrl is invalid publishTestMessage(rest) { error in guard let errorCode = testHTTPExecutor.responses.first?.allHeaderFields["X-Ably-Errorcode"] as? String else { diff --git a/Spec/RestClientChannels.swift b/Spec/RestClientChannels.swift index cbe47ceb7..001b0081c 100644 --- a/Spec/RestClientChannels.swift +++ b/Spec/RestClientChannels.swift @@ -124,7 +124,7 @@ class RestClientChannels: QuickSpec { it("should be enumerable") { let channels = [ client.channels.get(channelName), - client.channels.get(String(channelName.characters.reversed())) + client.channels.get(String(channelName.reversed())) ] for channel in client.channels { diff --git a/Spec/TestUtilities.swift b/Spec/TestUtilities.swift index caa877510..fe0e3d2de 100644 --- a/Spec/TestUtilities.swift +++ b/Spec/TestUtilities.swift @@ -305,7 +305,7 @@ class NSURLSessionServerTrustSync: NSObject, URLSessionDelegate, URLSessionTaskD task.resume() while !requestCompleted { - CFRunLoopRunInMode(CFRunLoopMode.defaultMode, CFTimeInterval(0.1), Bool(0)) + CFRunLoopRunInMode(CFRunLoopMode.defaultMode, CFTimeInterval(0.1), Bool(truncating: 0)) } return (responseData, responseError, httpResponse) @@ -816,7 +816,7 @@ class TestProxyTransport: ARTWebSocketTransport { func send(_ message: ARTProtocolMessage) { let data = try! encoder.encode(message) - send(data, withSource: message) + let _ = send(data, withSource: message) } override func send(_ data: Data, withSource decodedObject: Any?) -> Bool { @@ -893,7 +893,7 @@ class TestProxyTransport: ARTWebSocketTransport { override func webSocket(_ webSocket: SRWebSocket, didReceiveMessage message: Any?) { if !ignoreWebSocket { - super.webSocket(webSocket, didReceiveMessage: message) + super.webSocket(webSocket, didReceiveMessage: message as Any) } } @@ -999,8 +999,8 @@ extension NSRegularExpression { let range = NSMakeRange(0, value.lengthOfBytes(using: String.Encoding.utf8)) let result = regex.firstMatch(in: value, options: [], range: range) guard let textRange = result?.range(at: 0) else { return nil } - let convertedRange = value.characters.index(value.startIndex, offsetBy: textRange.location).. Data? { - let data = NSMutableData(capacity: characters.count / 2) + let data = NSMutableData(capacity: self.count / 2) let regex = try! NSRegularExpression(pattern: "[0-9a-f]{1,2}", options: .caseInsensitive) - regex.enumerateMatches(in: self, options: [], range: NSMakeRange(0, characters.count)) { match, flags, stop in + regex.enumerateMatches(in: self, options: [], range: NSMakeRange(0, self.count)) { match, flags, stop in let byteString = (self as NSString).substring(with: match!.range) var num = UInt8(byteString, radix: 16) data?.append(&num, length: 1) From b38a83fd191404dd8ef5838b8ed3bc90b7711ef1 Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Tue, 30 Jan 2018 09:45:53 +0100 Subject: [PATCH 15/16] Force cleaning the project on Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 18ee29e4b..0ef39ed2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,5 +17,5 @@ script: # Use `travis_wait` when a long running command or compile step regularly takes longer than 10 minutes without producing any output. # It writes a short line to the build log every minute for 20 minutes, extending the amount of time your command has to finish. # Prefix `travis_wait` with a greater number to extend the wait time. - - fastlane scan --scheme "Ably" --open_report false --devices "iPhone 6s" + - fastlane scan --scheme "Ably" --open_report false --devices "iPhone 6s" --clean - bash ./Scripts/run_examples_tests.sh From 6ad56198500c2570f740360ce9527cbb9d043eab Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Tue, 30 Jan 2018 11:43:13 +0100 Subject: [PATCH 16/16] Address warnings in Ably SDK --- Source/ARTChannels+Private.h | 2 +- Source/ARTChannels.m | 2 +- Source/ARTEventEmitter+Private.h | 2 +- Source/ARTEventEmitter.m | 4 ++-- Source/ARTRealtime.m | 2 +- Source/ARTRealtimeChannel.m | 2 +- Source/ARTRestChannel.m | 2 +- Source/ARTTypes.h | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/ARTChannels+Private.h b/Source/ARTChannels+Private.h index 668f206f1..aedc78f50 100644 --- a/Source/ARTChannels+Private.h +++ b/Source/ARTChannels+Private.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN -extern NSString* (^_Nullable ARTChannels_getChannelNamePrefix)(); +extern NSString* (^_Nullable ARTChannels_getChannelNamePrefix)(void); @protocol ARTChannelsDelegate diff --git a/Source/ARTChannels.m b/Source/ARTChannels.m index d80914e0f..aab93471c 100644 --- a/Source/ARTChannels.m +++ b/Source/ARTChannels.m @@ -13,7 +13,7 @@ #import "ARTChannelOptions.h" #import "ARTRestChannel.h" -NSString* (^_Nullable ARTChannels_getChannelNamePrefix)(); +NSString* (^_Nullable ARTChannels_getChannelNamePrefix)(void); @interface ARTChannels() { __weak id _delegate; diff --git a/Source/ARTEventEmitter+Private.h b/Source/ARTEventEmitter+Private.h index a0441e3b6..d06cc429e 100644 --- a/Source/ARTEventEmitter+Private.h +++ b/Source/ARTEventEmitter+Private.h @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init NS_UNAVAILABLE; - (instancetype)initWithId:(NSString *)eventId token:(id)token handler:(ARTEventEmitter *)eventHandler center:(NSNotificationCenter *)center; -- (ARTEventListener *)setTimer:(NSTimeInterval)timeoutDeadline onTimeout:(void (^)())timeoutBlock; +- (ARTEventListener *)setTimer:(NSTimeInterval)timeoutDeadline onTimeout:(void (^)(void))timeoutBlock; - (void)startTimer; - (void)stopTimer; diff --git a/Source/ARTEventEmitter.m b/Source/ARTEventEmitter.m index 9a7aef840..212facd5e 100644 --- a/Source/ARTEventEmitter.m +++ b/Source/ARTEventEmitter.m @@ -63,7 +63,7 @@ @implementation ARTEventListener { __weak NSNotificationCenter *_center; __weak ARTEventEmitter *_eventHandler; NSTimeInterval _timeoutDeadline; - void (^_timeoutBlock)(); + void (^_timeoutBlock)(void); dispatch_block_t _work; } @@ -107,7 +107,7 @@ - (void)invalidate { [self stopTimer]; } -- (ARTEventListener *)setTimer:(NSTimeInterval)timeoutDeadline onTimeout:(void (^)())timeoutBlock { +- (ARTEventListener *)setTimer:(NSTimeInterval)timeoutDeadline onTimeout:(void (^)(void))timeoutBlock { if (_timeoutBlock) { NSAssert(false, @"timer is already set"); } diff --git a/Source/ARTRealtime.m b/Source/ARTRealtime.m index c85a07ff6..12cedd9c6 100644 --- a/Source/ARTRealtime.m +++ b/Source/ARTRealtime.m @@ -548,7 +548,7 @@ - (ARTEventListener *)transitionSideEffects:(ARTConnectionStateChange *)stateCha } ART_TRY_OR_MOVE_TO_FAILED_END } -- (ARTEventListener *)unlessStateChangesBefore:(NSTimeInterval)deadline do:(void(^)())callback __attribute__((warn_unused_result)) { +- (ARTEventListener *)unlessStateChangesBefore:(NSTimeInterval)deadline do:(void(^)(void))callback __attribute__((warn_unused_result)) { return [[_internalEventEmitter once:^(ARTConnectionStateChange *change) { // Any state change cancels the timeout. }] setTimer:deadline onTimeout:^{ diff --git a/Source/ARTRealtimeChannel.m b/Source/ARTRealtimeChannel.m index abc3475f7..f91576b81 100644 --- a/Source/ARTRealtimeChannel.m +++ b/Source/ARTRealtimeChannel.m @@ -521,7 +521,7 @@ - (void)transition:(ARTRealtimeChannelState)state status:(ARTStatus *)status { } ART_TRY_OR_MOVE_TO_FAILED_END } -- (ARTEventListener *)unlessStateChangesBefore:(NSTimeInterval)deadline do:(void(^)())callback { +- (ARTEventListener *)unlessStateChangesBefore:(NSTimeInterval)deadline do:(void(^)(void))callback { ART_TRY_OR_MOVE_TO_FAILED_START(_realtime) { return [[self.internalEventEmitter once:^(ARTChannelStateChange *stateChange) { // Any state change cancels the timeout. diff --git a/Source/ARTRestChannel.m b/Source/ARTRestChannel.m index 330137087..fc0ca4784 100644 --- a/Source/ARTRestChannel.m +++ b/Source/ARTRestChannel.m @@ -70,7 +70,7 @@ - (void)history:(void (^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *, ARTErro } ART_TRY_OR_REPORT_CRASH_END } -- (BOOL)history:(ARTDataQuery *)query callback:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *result, ARTErrorInfo *error))callback error:(NSError **)errorPtr { +- (BOOL)history:(ARTDataQuery *)query callback:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *result, ARTErrorInfo *error))callback error:(NSError * __autoreleasing *)errorPtr { if (callback) { void (^userCallback)(__GENERIC(ARTPaginatedResult, ARTMessage *) *result, ARTErrorInfo *error) = callback; callback = ^(__GENERIC(ARTPaginatedResult, ARTMessage *) *result, ARTErrorInfo *error) { diff --git a/Source/ARTTypes.h b/Source/ARTTypes.h index 1e4475133..c9f66ee77 100644 --- a/Source/ARTTypes.h +++ b/Source/ARTTypes.h @@ -121,7 +121,7 @@ uint64_t dateToMilliseconds(NSDate *date); uint64_t timeIntervalToMilliseconds(NSTimeInterval seconds); NSTimeInterval millisecondsToTimeInterval(uint64_t msecs); -NSString *generateNonce(); +NSString *generateNonce(void); // FIXME: review @protocol ARTCancellable