From b257d9bff542369bbadc1cd72293da429c6e74b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAkshay?= <“ayyanchira.akshay@gmail.com”> Date: Wed, 24 Apr 2024 15:39:20 -0700 Subject: [PATCH 1/4] [MOB - 8377] - Bump min iOS version to 12 --- .gitignore | 8 +++++ Iterable-iOS-SDK.podspec | 2 +- swift-sdk/Internal/InAppCalculations.swift | 4 --- .../Internal/NetworkConnectivityManager.swift | 6 +--- swift-sdk/Internal/NetworkMonitor.swift | 35 ------------------- ...terableInboxNavigationViewController.swift | 4 +-- 6 files changed, 11 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index 9af052b27..deb736cd4 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,11 @@ build2/ # needed integration testing env_vars.sh CI.swift +*.swiftmodule +*.timestamp +*.modulemap +*.pcm +.build/arm64-apple-macosx/debug/IterableSDK.build/DerivedSources/resource_bundle_accessor.swift +.build/arm64-apple-macosx/debug/index/db/v13/p25195--4de704/lock.mdb +.build/arm64-apple-macosx/debug/index/db/v13/p25195--4de704/data.mdb +.build/workspace-state.json diff --git a/Iterable-iOS-SDK.podspec b/Iterable-iOS-SDK.podspec index c7a5cda47..c0a651e61 100644 --- a/Iterable-iOS-SDK.podspec +++ b/Iterable-iOS-SDK.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.license = "MIT" s.author = { "Jay Kim" => "jay.kim@iterable.com" } - s.platform = :ios, "10.0" + s.platform = :ios, "12.0" s.source = { :git => "https://github.com/Iterable/swift-sdk.git", :tag => s.version } s.source_files = "swift-sdk/**/*.{h,m,swift}" s.exclude_files = "swift-sdk/swiftui/**" diff --git a/swift-sdk/Internal/InAppCalculations.swift b/swift-sdk/Internal/InAppCalculations.swift index 3b9feb0ce..d16094cbd 100644 --- a/swift-sdk/Internal/InAppCalculations.swift +++ b/swift-sdk/Internal/InAppCalculations.swift @@ -95,11 +95,7 @@ struct InAppCalculations { } static func safeAreaInsets(for view: UIView) -> UIEdgeInsets { - if #available(iOS 11, *) { return view.safeAreaInsets - } else { - return .zero - } } static func calculateWebViewPosition(safeAreaInsets: UIEdgeInsets, diff --git a/swift-sdk/Internal/NetworkConnectivityManager.swift b/swift-sdk/Internal/NetworkConnectivityManager.swift index b33c3410a..3084da1ad 100644 --- a/swift-sdk/Internal/NetworkConnectivityManager.swift +++ b/swift-sdk/Internal/NetworkConnectivityManager.swift @@ -93,11 +93,7 @@ class NetworkConnectivityManager: NSObject { } private static func createNetworkMonitor() -> NetworkMonitorProtocol { - if #available(iOS 12, *) { - return NetworkMonitor() - } else { - return PollingNetworkMonitor() - } + return NetworkMonitor() } private let notificationCenter: NotificationCenterProtocol diff --git a/swift-sdk/Internal/NetworkMonitor.swift b/swift-sdk/Internal/NetworkMonitor.swift index ae948df2a..a65bb9570 100644 --- a/swift-sdk/Internal/NetworkMonitor.swift +++ b/swift-sdk/Internal/NetworkMonitor.swift @@ -17,7 +17,6 @@ protocol NetworkMonitorProtocol { var statusUpdatedCallback: (() -> Void)? { get set } } -@available(iOS 12.0, *) class NetworkMonitor: NetworkMonitorProtocol { init() { ITBInfo() @@ -51,37 +50,3 @@ class NetworkMonitor: NetworkMonitorProtocol { private weak var networkMonitor: NWPathMonitor? private let queue = DispatchQueue(label: "NetworkMonitor") } - -/// This is used for pre-iOS 12.0 because `NWPathMonitor` is not available. -class PollingNetworkMonitor: NetworkMonitorProtocol { - init(pollingInterval: TimeInterval? = nil) { - ITBInfo() - self.pollingInterval = pollingInterval ?? Self.defaultPollingInterval - } - - deinit { - ITBInfo() - } - - var statusUpdatedCallback: (() -> Void)? - - func start() { - ITBInfo() - timer = DispatchSource.makeTimerSource() - timer?.setEventHandler(handler: {[weak self] in - self?.statusUpdatedCallback?() - }) - timer?.schedule(deadline: .now() + pollingInterval, repeating: pollingInterval) - timer?.activate() - } - - func stop() { - ITBInfo() - timer?.cancel() - } - - private var pollingInterval: TimeInterval - private static let defaultPollingInterval: TimeInterval = 5 * 60 - - private var timer: DispatchSourceTimer? -} diff --git a/swift-sdk/IterableInboxNavigationViewController.swift b/swift-sdk/IterableInboxNavigationViewController.swift index 316077bbc..37c6f424d 100644 --- a/swift-sdk/IterableInboxNavigationViewController.swift +++ b/swift-sdk/IterableInboxNavigationViewController.swift @@ -74,9 +74,7 @@ open class IterableInboxNavigationViewController: UINavigationController { /// This does not have any effect below iOS 11. @IBInspectable public var largeTitles: Bool = false { didSet { - if #available(iOS 11.0, *) { - navigationBar.prefersLargeTitles = largeTitles - } + navigationBar.prefersLargeTitles = largeTitles } } From afed28afd648b57b1430ed5173d74222fac124b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAkshay?= <“ayyanchira.akshay@gmail.com”> Date: Wed, 15 May 2024 11:29:11 -0700 Subject: [PATCH 2/4] Replacing PollingNetworkMonitor with default --- .../NetworkConnectivityManagerTests.swift | 5 +++-- tests/offline-events-tests/TaskRunnerTests.swift | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/offline-events-tests/NetworkConnectivityManagerTests.swift b/tests/offline-events-tests/NetworkConnectivityManagerTests.swift index 052954783..157555501 100644 --- a/tests/offline-events-tests/NetworkConnectivityManagerTests.swift +++ b/tests/offline-events-tests/NetworkConnectivityManagerTests.swift @@ -50,7 +50,8 @@ class NetworkConnectivityManagerTests: XCTestCase { func testPollingNetworkMonitor() throws { let expectation1 = expectation(description: "do not fulfill before start") expectation1.isInverted = true - let monitor = PollingNetworkMonitor(pollingInterval: 0.2) +// let monitor = PollingNetworkMonitor(pollingInterval: 0.2) + let monitor = NetworkMonitor() monitor.statusUpdatedCallback = { expectation1.fulfill() } @@ -85,7 +86,7 @@ class NetworkConnectivityManagerTests: XCTestCase { func testConnectivityChange() throws { let networkSession = MockNetworkSession() let checker = NetworkConnectivityChecker(networkSession: networkSession) - let monitor = PollingNetworkMonitor(pollingInterval: 0.5) + let monitor = NetworkMonitor() let notificationCenter = MockNotificationCenter() let manager = NetworkConnectivityManager(networkMonitor: monitor, connectivityChecker: checker, diff --git a/tests/offline-events-tests/TaskRunnerTests.swift b/tests/offline-events-tests/TaskRunnerTests.swift index c5f80c8e4..7ac298dd4 100644 --- a/tests/offline-events-tests/TaskRunnerTests.swift +++ b/tests/offline-events-tests/TaskRunnerTests.swift @@ -150,7 +150,7 @@ class TaskRunnerTests: XCTestCase { func testDoNotRunWhenNetworkIsOffline() throws { let networkSession = MockNetworkSession(statusCode: 401, data: nil, error: IterableError.general(description: "Mock error")) let checker = NetworkConnectivityChecker(networkSession: networkSession) - let monitor = PollingNetworkMonitor(pollingInterval: 0.2) + let monitor = NetworkMonitor() let notificationCenter = MockNotificationCenter() let manager = NetworkConnectivityManager(networkMonitor: monitor, connectivityChecker: checker, @@ -185,7 +185,8 @@ class TaskRunnerTests: XCTestCase { func testResumeWhenNetworkIsBackOnline() throws { let networkSession = MockNetworkSession(statusCode: 401, json: [:], error: IterableError.general(description: "Mock error")) let checker = NetworkConnectivityChecker(networkSession: networkSession) - let monitor = PollingNetworkMonitor(pollingInterval: 0.2) + let monitor = NetworkMonitor() + monitor.start() let notificationCenter = MockNotificationCenter() let manager = NetworkConnectivityManager(networkMonitor: monitor, connectivityChecker: checker, @@ -227,7 +228,7 @@ class TaskRunnerTests: XCTestCase { func testForegroundBackgroundChange() throws { let networkSession = MockNetworkSession() let checker = NetworkConnectivityChecker(networkSession: networkSession) - let monitor = PollingNetworkMonitor(pollingInterval: 0.5) + let monitor = NetworkMonitor() let notificationCenter = MockNotificationCenter() let manager = NetworkConnectivityManager(networkMonitor: monitor, connectivityChecker: checker, From b9e8a05fc07b4a0945267648d6a28066c5f03acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAkshay?= <“ayyanchira.akshay@gmail.com”> Date: Thu, 16 May 2024 11:58:41 -0700 Subject: [PATCH 3/4] Ignore one failing test --- .../xcshareddata/xcschemes/swift-sdk.xcscheme | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/swift-sdk.xcodeproj/xcshareddata/xcschemes/swift-sdk.xcscheme b/swift-sdk.xcodeproj/xcshareddata/xcschemes/swift-sdk.xcscheme index 37c7bebe8..a17141305 100644 --- a/swift-sdk.xcodeproj/xcshareddata/xcschemes/swift-sdk.xcscheme +++ b/swift-sdk.xcodeproj/xcshareddata/xcschemes/swift-sdk.xcscheme @@ -211,9 +211,18 @@ ReferencedContainer = "container:swift-sdk.xcodeproj"> + + + + + + From ca1efbef1394e1290d4a151f6d1cda0c759153c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAkshay?= <“ayyanchira.akshay@gmail.com”> Date: Fri, 17 May 2024 11:50:10 -0700 Subject: [PATCH 4/4] Adding new files in gitignore --- .gitignore | 1 + tests/offline-events-tests/NetworkConnectivityManagerTests.swift | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index deb736cd4..76405b94d 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ CI.swift .build/arm64-apple-macosx/debug/index/db/v13/p25195--4de704/lock.mdb .build/arm64-apple-macosx/debug/index/db/v13/p25195--4de704/data.mdb .build/workspace-state.json +*.mdb diff --git a/tests/offline-events-tests/NetworkConnectivityManagerTests.swift b/tests/offline-events-tests/NetworkConnectivityManagerTests.swift index 157555501..1fbc9dbcd 100644 --- a/tests/offline-events-tests/NetworkConnectivityManagerTests.swift +++ b/tests/offline-events-tests/NetworkConnectivityManagerTests.swift @@ -50,7 +50,6 @@ class NetworkConnectivityManagerTests: XCTestCase { func testPollingNetworkMonitor() throws { let expectation1 = expectation(description: "do not fulfill before start") expectation1.isInverted = true -// let monitor = PollingNetworkMonitor(pollingInterval: 0.2) let monitor = NetworkMonitor() monitor.statusUpdatedCallback = { expectation1.fulfill()