Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 4: upgrade settings and dependencies #671

Merged
merged 16 commits into from
Jan 31, 2018
Merged
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8.3
osx_image: xcode9.2
env:
global:
- LC_CTYPE=en_US.UTF-8
Expand All @@ -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
31 changes: 25 additions & 6 deletions Ably.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,9 @@
FAFEC5BB8312EB69E84C28D4 /* Frameworks */,
514B60993BD8A01B13ECB1BC /* Pods */,
);
indentWidth = 4;
sourceTree = "<group>";
tabWidth = 4;
};
96BF61321A35B2AB004CF2B3 /* Products */ = {
isa = PBXGroup;
Expand Down Expand Up @@ -913,15 +915,16 @@
attributes = {
CLASSPREFIX = ART;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = Ably;
TargetAttributes = {
856AAC891B6E304B00B07119 = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0820;
LastSwiftMigration = 0920;
};
96BF61301A35B2AB004CF2B3 = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 0920;
};
};
};
Expand Down Expand Up @@ -1156,7 +1159,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;
};
Expand All @@ -1178,7 +1182,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;
};
Expand All @@ -1190,14 +1195,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;
Expand Down Expand Up @@ -1239,14 +1250,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;
Expand Down Expand Up @@ -1294,7 +1311,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;
};
Expand All @@ -1317,7 +1335,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;
};
Expand Down
4 changes: 3 additions & 1 deletion Ably.xcodeproj/xcshareddata/xcschemes/Ably.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,6 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "NO">
<Testables>
<TestableReference
Expand Down Expand Up @@ -76,6 +77,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 3 additions & 1 deletion Ably.xcodeproj/xcshareddata/xcschemes/AblySpec.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "NO">
<Testables>
<TestableReference
Expand Down Expand Up @@ -53,6 +54,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
16 changes: 8 additions & 8 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -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.3.1
COCOAPODS: 1.4.0
4 changes: 2 additions & 2 deletions Scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -e

# Install Fastlane
gem install fastlane
gem install fastlane -v 2.77.1

# Install CocoaPods
gem install cocoapods
Expand All @@ -14,4 +14,4 @@ brew update && brew install carthage

# Install dependencies
pod install
carthage bootstrap
carthage bootstrap
2 changes: 1 addition & 1 deletion Source/ARTChannels+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

NS_ASSUME_NONNULL_BEGIN

extern NSString* (^_Nullable ARTChannels_getChannelNamePrefix)();
extern NSString* (^_Nullable ARTChannels_getChannelNamePrefix)(void);

@protocol ARTChannelsDelegate <NSObject>

Expand Down
2 changes: 1 addition & 1 deletion Source/ARTChannels.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import "ARTChannelOptions.h"
#import "ARTRestChannel.h"

NSString* (^_Nullable ARTChannels_getChannelNamePrefix)();
NSString* (^_Nullable ARTChannels_getChannelNamePrefix)(void);

@interface ARTChannels() {
__weak id<ARTChannelsDelegate> _delegate;
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTEventEmitter+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithId:(NSString *)eventId token:(id<NSObject>)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;

Expand Down
4 changes: 2 additions & 2 deletions Source/ARTEventEmitter.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ @implementation ARTEventListener {
__weak NSNotificationCenter *_center;
__weak ARTEventEmitter *_eventHandler;
NSTimeInterval _timeoutDeadline;
void (^_timeoutBlock)();
void (^_timeoutBlock)(void);
dispatch_block_t _work;
}

Expand Down Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTRealtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -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:^{
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTRealtimeChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTRestChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions Spec/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1986,15 +1986,15 @@ 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
expect(error).to(beNil())
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))
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion Spec/RealtimeClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion Spec/RealtimeClientChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Loading