From 757666c8a26aec1c015fa22c7a9db97dd084bb0d Mon Sep 17 00:00:00 2001 From: Tapash Majumder Date: Thu, 31 Jan 2019 15:53:42 -0800 Subject: [PATCH 1/2] Update to swift-4.2 --- .../IterableAPITests.swift | 4 +-- .../IterableInAppNotificationTests.swift | 18 ++++++------- host-app/AppDelegate.swift | 2 +- swift-sdk.xcodeproj/project.pbxproj | 26 ++++++++++--------- swift-sdk/Internal/IterableAPIInternal.swift | 8 +++--- .../IterableAppIntegrationInternal.swift | 2 +- .../IterableInAppHTMLViewController.swift | 2 +- swift-sdk/IterableAPI.swift | 4 +-- 8 files changed, 34 insertions(+), 32 deletions(-) diff --git a/Tests/swift-sdk-swift-tests/IterableAPITests.swift b/Tests/swift-sdk-swift-tests/IterableAPITests.swift index 9265cf495..ee231c0d7 100644 --- a/Tests/swift-sdk-swift-tests/IterableAPITests.swift +++ b/Tests/swift-sdk-swift-tests/IterableAPITests.swift @@ -593,7 +593,7 @@ class IterableAPITests: XCTestCase { ] ] ] - let launchOptions: [UIApplicationLaunchOptionsKey : Any] = [UIApplicationLaunchOptionsKey.remoteNotification : userInfo] + let launchOptions: [UIApplication.LaunchOptionsKey : Any] = [UIApplication.LaunchOptionsKey.remoteNotification : userInfo] let customActionDelegate = MockCustomActionDelegate(returnValue: false) customActionDelegate.callback = {(name, _) in XCTAssertEqual(name, "customAction") @@ -622,7 +622,7 @@ class IterableAPITests: XCTestCase { ] ] ] - let launchOptions: [UIApplicationLaunchOptionsKey : Any] = [UIApplicationLaunchOptionsKey.remoteNotification : userInfo] + let launchOptions: [UIApplication.LaunchOptionsKey : Any] = [UIApplication.LaunchOptionsKey.remoteNotification : userInfo] let urlDelegate = MockUrlDelegate(returnValue: true) urlDelegate.callback = {(url, _) in XCTAssertEqual(url.absoluteString, "http://somewhere.com") diff --git a/Tests/swift-sdk-swift-tests/IterableInAppNotificationTests.swift b/Tests/swift-sdk-swift-tests/IterableInAppNotificationTests.swift index 780d22d21..243cbd2d6 100644 --- a/Tests/swift-sdk-swift-tests/IterableInAppNotificationTests.swift +++ b/Tests/swift-sdk-swift-tests/IterableInAppNotificationTests.swift @@ -45,7 +45,7 @@ class IterableInAppNotificationTests: XCTestCase { func testGetPaddingInvalid() { let insets = IterableInAppManager.getPaddingFromPayload([:]) - XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(insets, UIEdgeInsets.zero)) + XCTAssertEqual(insets, UIEdgeInsets.zero) } func testGetPaddingFull() { @@ -57,14 +57,14 @@ class IterableInAppNotificationTests: XCTestCase { ] let insets = IterableInAppManager.getPaddingFromPayload(payload) - XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(insets, UIEdgeInsets.zero)) + XCTAssertEqual(insets, UIEdgeInsets.zero) var padding = UIEdgeInsets.zero padding.top = CGFloat(IterableInAppManager.decodePadding(payload["top"])) padding.left = CGFloat(IterableInAppManager.decodePadding(payload["left"])) padding.bottom = CGFloat(IterableInAppManager.decodePadding(payload["bottom"])) padding.right = CGFloat(IterableInAppManager.decodePadding(payload["right"])) - XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(padding, UIEdgeInsets.zero)) + XCTAssertEqual(padding, UIEdgeInsets.zero) } func testGetPaddingCenter() { @@ -76,14 +76,14 @@ class IterableInAppNotificationTests: XCTestCase { ] let insets = IterableInAppManager.getPaddingFromPayload(payload) - XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(insets, UIEdgeInsets(top: -1, left: 0, bottom: -1, right: 0))) + XCTAssertEqual(insets, UIEdgeInsets(top: -1, left: 0, bottom: -1, right: 0)) var padding = UIEdgeInsets.zero padding.top = CGFloat(IterableInAppManager.decodePadding(payload["top"])) padding.left = CGFloat(IterableInAppManager.decodePadding(payload["left"])) padding.bottom = CGFloat(IterableInAppManager.decodePadding(payload["bottom"])) padding.right = CGFloat(IterableInAppManager.decodePadding(payload["right"])) - XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(padding, UIEdgeInsets(top: -1, left: 0, bottom: -1, right: 0))) + XCTAssertEqual(padding, UIEdgeInsets(top: -1, left: 0, bottom: -1, right: 0)) } func testGetPaddingTop() { @@ -95,14 +95,14 @@ class IterableInAppNotificationTests: XCTestCase { ] let insets = IterableInAppManager.getPaddingFromPayload(payload) - XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(insets, UIEdgeInsets(top: 0, left: 0, bottom: -1, right: 0))) + XCTAssertEqual(insets, UIEdgeInsets(top: 0, left: 0, bottom: -1, right: 0)) var padding = UIEdgeInsets.zero padding.top = CGFloat(IterableInAppManager.decodePadding(payload["top"])) padding.left = CGFloat(IterableInAppManager.decodePadding(payload["left"])) padding.bottom = CGFloat(IterableInAppManager.decodePadding(payload["bottom"])) padding.right = CGFloat(IterableInAppManager.decodePadding(payload["right"])) - XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(padding, UIEdgeInsets(top: 0, left: 0, bottom: -1, right: 0))) + XCTAssertEqual(padding, UIEdgeInsets(top: 0, left: 0, bottom: -1, right: 0)) } func testGetPaddingBottom() { @@ -114,14 +114,14 @@ class IterableInAppNotificationTests: XCTestCase { ] let insets = IterableInAppManager.getPaddingFromPayload(payload) - XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(insets, UIEdgeInsets(top: -1, left: 0, bottom: 0, right: 0))) + XCTAssertEqual(insets, UIEdgeInsets(top: -1, left: 0, bottom: 0, right: 0)) var padding = UIEdgeInsets.zero padding.top = CGFloat(IterableInAppManager.decodePadding(payload["top"])) padding.left = CGFloat(IterableInAppManager.decodePadding(payload["left"])) padding.bottom = CGFloat(IterableInAppManager.decodePadding(payload["bottom"])) padding.right = CGFloat(IterableInAppManager.decodePadding(payload["right"])) - XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(padding, UIEdgeInsets(top: -1, left: 0, bottom: 0, right: 0))) + XCTAssertEqual(padding, UIEdgeInsets(top: -1, left: 0, bottom: 0, right: 0)) } func testNotificationPaddingFull() { diff --git a/host-app/AppDelegate.swift b/host-app/AppDelegate.swift index 1977c380a..6126a196a 100644 --- a/host-app/AppDelegate.swift +++ b/host-app/AppDelegate.swift @@ -17,7 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. let config = IterableConfig() diff --git a/swift-sdk.xcodeproj/project.pbxproj b/swift-sdk.xcodeproj/project.pbxproj index 34c1db37d..d1051bf66 100644 --- a/swift-sdk.xcodeproj/project.pbxproj +++ b/swift-sdk.xcodeproj/project.pbxproj @@ -1173,6 +1173,7 @@ SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.2; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1230,6 +1231,7 @@ SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_VERSION = 4.2; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1260,7 +1262,7 @@ PRODUCT_NAME = IterableSDK; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1290,7 +1292,7 @@ PRODUCT_NAME = IterableSDK; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -1310,7 +1312,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "iterable.swift-sdk-swift-tests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/host-app.app/host-app"; }; @@ -1331,7 +1333,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "iterable.swift-sdk-swift-tests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/host-app.app/host-app"; }; @@ -1364,7 +1366,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/swift-sdk-objc-tests/swift-sdk-objc-tests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/host-app.app/host-app"; }; @@ -1396,7 +1398,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "iterable.swift-sdk-objc-tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/swift-sdk-objc-tests/swift-sdk-objc-tests-Bridging-Header.h"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/host-app.app/host-app"; }; @@ -1428,7 +1430,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1458,7 +1460,7 @@ PRODUCT_NAME = IterableAppExtensions; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -1481,7 +1483,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/notification-extension-tests/notification-extensionTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/host-app.app/host-app"; }; @@ -1504,7 +1506,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "iterable.notification-extensionTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/notification-extension-tests/notification-extensionTests-Bridging-Header.h"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/host-app.app/host-app"; }; @@ -1569,7 +1571,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "iterable.host-app"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1590,7 +1592,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "iterable.host-app"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/swift-sdk/Internal/IterableAPIInternal.swift b/swift-sdk/Internal/IterableAPIInternal.swift index 94c644e9c..7071dc416 100644 --- a/swift-sdk/Internal/IterableAPIInternal.swift +++ b/swift-sdk/Internal/IterableAPIInternal.swift @@ -668,7 +668,7 @@ final class IterableAPIInternal : NSObject, PushTrackerProtocol { // MARK: Initialization // Package private method. Do not call this directly. init(apiKey: String, - launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil, + launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil, config: IterableConfig = IterableConfig(), dateProvider: DateProviderProtocol = SystemDateProvider(), networkSession: @escaping @autoclosure () -> NetworkSessionProtocol = URLSession(configuration: URLSessionConfiguration.default), @@ -710,7 +710,7 @@ final class IterableAPIInternal : NSObject, PushTrackerProtocol { } static func initialize(apiKey: String, - launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil, + launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil, config: IterableConfig = IterableConfig()) -> IterableAPIInternal { queue.sync { _sharedInstance = IterableAPIInternal(apiKey: apiKey, @@ -722,11 +722,11 @@ final class IterableAPIInternal : NSObject, PushTrackerProtocol { return _sharedInstance! } - private func handle(launchOptions: [UIApplicationLaunchOptionsKey: Any]?) { + private func handle(launchOptions: [UIApplication.LaunchOptionsKey: Any]?) { guard let launchOptions = launchOptions else { return } - if let remoteNotificationPayload = launchOptions[UIApplicationLaunchOptionsKey.remoteNotification] as? [AnyHashable : Any] { + if let remoteNotificationPayload = launchOptions[UIApplication.LaunchOptionsKey.remoteNotification] as? [AnyHashable : Any] { if let _ = IterableUtil.rootViewController { // we are ready IterableAppIntegration.implementation?.performDefaultNotificationAction(remoteNotificationPayload) diff --git a/swift-sdk/Internal/IterableAppIntegrationInternal.swift b/swift-sdk/Internal/IterableAppIntegrationInternal.swift index b822f67f1..3bc1904a5 100644 --- a/swift-sdk/Internal/IterableAppIntegrationInternal.swift +++ b/swift-sdk/Internal/IterableAppIntegrationInternal.swift @@ -86,7 +86,7 @@ struct UserNotificationResponse : NotificationResponseProtocol { /// Abstraction of applicationState @objc public protocol ApplicationStateProviderProtocol : class { - @objc var applicationState: UIApplicationState {get} + @objc var applicationState: UIApplication.State {get} } extension UIApplication : ApplicationStateProviderProtocol { diff --git a/swift-sdk/Internal/IterableInAppHTMLViewController.swift b/swift-sdk/Internal/IterableInAppHTMLViewController.swift index e0e1c18ed..0789cbff4 100644 --- a/swift-sdk/Internal/IterableInAppHTMLViewController.swift +++ b/swift-sdk/Internal/IterableInAppHTMLViewController.swift @@ -202,7 +202,7 @@ extension IterableInAppHTMLViewController : UIWebViewDelegate { } } - func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool { + func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebView.NavigationType) -> Bool { guard navigationType == .linkClicked, let url = request.url else { return true } diff --git a/swift-sdk/IterableAPI.swift b/swift-sdk/IterableAPI.swift index 83625784b..32d8973b1 100644 --- a/swift-sdk/IterableAPI.swift +++ b/swift-sdk/IterableAPI.swift @@ -33,7 +33,7 @@ public final class IterableAPI : NSObject { /// - parameter apiKey: Iterable API Key. /// - parameter launchOptions: The launchOptions coming from application:didLaunching:withOptions public static func initialize(apiKey: String, - launchOptions: [UIApplicationLaunchOptionsKey: Any]?) { + launchOptions: [UIApplication.LaunchOptionsKey: Any]?) { initialize(apiKey: apiKey, launchOptions: launchOptions, config: IterableConfig()) } @@ -42,7 +42,7 @@ public final class IterableAPI : NSObject { /// - parameter launchOptions: The launchOptions coming from application:didLaunching:withOptions /// - parameter config: Iterable config object. public static func initialize(apiKey: String, - launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil, + launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil, config: IterableConfig = IterableConfig()) { internalImplementation = IterableAPIInternal.initialize(apiKey: apiKey, launchOptions: launchOptions, config:config) } From 8009c15fe8ea506f23eeef10d0fc12c9f826ee03 Mon Sep 17 00:00:00 2001 From: Tapash Majumder Date: Thu, 31 Jan 2019 16:00:21 -0800 Subject: [PATCH 2/2] Update SDK version and podspec. --- Iterable-iOS-AppExtensions.podspec | 6 +++--- Iterable-iOS-SDK.podspec | 6 +++--- swift-sdk/IterableAPI.swift | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Iterable-iOS-AppExtensions.podspec b/Iterable-iOS-AppExtensions.podspec index b64b4a0ea..74fd7fd34 100644 --- a/Iterable-iOS-AppExtensions.podspec +++ b/Iterable-iOS-AppExtensions.podspec @@ -17,7 +17,7 @@ Pod::Spec.new do |s| s.name = "Iterable-iOS-AppExtensions" s.module_name = "IterableAppExtensions" - s.version = "6.0.5" + s.version = "6.0.6" s.summary = "App Extensions for Iterable SDK" s.description = <<-DESC @@ -80,8 +80,8 @@ Pod::Spec.new do |s| # s.public_header_files = "Classes/**/*.h" s.pod_target_xcconfig = { - 'SWIFT_VERSION' => '4.1' + 'SWIFT_VERSION' => '4.2' } - s.swift_version = '4.1' + s.swift_version = '4.2' end diff --git a/Iterable-iOS-SDK.podspec b/Iterable-iOS-SDK.podspec index 75d28fb5f..effe48cae 100644 --- a/Iterable-iOS-SDK.podspec +++ b/Iterable-iOS-SDK.podspec @@ -17,7 +17,7 @@ Pod::Spec.new do |s| s.name = "Iterable-iOS-SDK" s.module_name = "IterableSDK" - s.version = "6.0.5" + s.version = "6.0.6" s.summary = "Iterable's official SDK for iOS" s.description = <<-DESC @@ -75,8 +75,8 @@ Pod::Spec.new do |s| s.source_files = "swift-sdk/**/*.{h,m,swift}" s.pod_target_xcconfig = { - 'SWIFT_VERSION' => '4.1' + 'SWIFT_VERSION' => '4.2' } - s.swift_version = '4.1' + s.swift_version = '4.2' end diff --git a/swift-sdk/IterableAPI.swift b/swift-sdk/IterableAPI.swift index 32d8973b1..88cbe2b4d 100644 --- a/swift-sdk/IterableAPI.swift +++ b/swift-sdk/IterableAPI.swift @@ -12,7 +12,7 @@ import Foundation @objcMembers public final class IterableAPI : NSObject { // Current SDK Version. - static let sdkVersion = "6.0.5" + static let sdkVersion = "6.0.6" // MARK: Initialization /// You should call this method and not call the init method directly.