Skip to content

Commit

Permalink
Merge pull request #45 from Iterable/feature/mob-153-upgrade-to-swift…
Browse files Browse the repository at this point in the history
…-4_2

[MOB-153] - Update to Swift 4.2
  • Loading branch information
tapashmajumder committed Feb 1, 2019
2 parents c2f3582 + 8009c15 commit ad6ddb3
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 39 deletions.
6 changes: 3 additions & 3 deletions Iterable-iOS-AppExtensions.podspec
Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions Iterable-iOS-SDK.podspec
Expand Up @@ -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
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions Tests/swift-sdk-swift-tests/IterableAPITests.swift
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
18 changes: 9 additions & 9 deletions Tests/swift-sdk-swift-tests/IterableInAppNotificationTests.swift
Expand Up @@ -45,7 +45,7 @@ class IterableInAppNotificationTests: XCTestCase {

func testGetPaddingInvalid() {
let insets = IterableInAppManager.getPaddingFromPayload([:])
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(insets, UIEdgeInsets.zero))
XCTAssertEqual(insets, UIEdgeInsets.zero)
}

func testGetPaddingFull() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion host-app/AppDelegate.swift
Expand Up @@ -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()
Expand Down
26 changes: 14 additions & 12 deletions swift-sdk.xcodeproj/project.pbxproj
Expand Up @@ -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 = "";
};
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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";
};
Expand All @@ -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";
};
Expand Down Expand Up @@ -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";
};
Expand Down Expand Up @@ -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";
};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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";
};
Expand All @@ -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";
};
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions swift-sdk/Internal/IterableAPIInternal.swift
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion swift-sdk/Internal/IterableAppIntegrationInternal.swift
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion swift-sdk/Internal/IterableInAppHTMLViewController.swift
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions swift-sdk/IterableAPI.swift
Expand Up @@ -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.
Expand All @@ -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())
}

Expand All @@ -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)
}
Expand Down

0 comments on commit ad6ddb3

Please sign in to comment.