Skip to content

Commit 3fd8d8a

Browse files
authored
[FSSDK-8918] fix: clean up UIKit import errors (#502)
1 parent a59c90c commit 3fd8d8a

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Optimizely Swift SDK Changelog
22

33
## 4.0.0-beta
4-
April 28, 2023
4+
May 1, 2023
55

66
### New Features
77

Scripts/build_all.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ main() {
3232

3333
xcodebuild -workspace OptimizelySwiftSDK.xcworkspace -scheme OptimizelySwiftSDK-iOS -configuration Release "${action}"
3434
xcodebuild -workspace OptimizelySwiftSDK.xcworkspace -scheme OptimizelySwiftSDK-tvOS -configuration Release "${action}"
35+
xcodebuild -workspace OptimizelySwiftSDK.xcworkspace -scheme OptimizelySwiftSDK-macOS -configuration Release "${action}"
36+
xcodebuild -workspace OptimizelySwiftSDK.xcworkspace -scheme OptimizelySwiftSDK-watchOS -configuration Release "${action}"
3537
}
3638

3739
main

Scripts/run_prep.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
# Additionally, it needs the following environment variables:
88
# VERSION - defined in swift.yml
99

10-
11-
set -x
12-
13-
1410
COLOR_RESET='\033[0m'
1511
COLOR_MAGENTA='\033[0;35m'
1612
COLOR_CYAN='\033[0;36m'

Sources/Protocols/BackgroundingCallbacks.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
//
1616

1717
import Foundation
18-
#if os(macOS)
18+
19+
#if os(watchOS)
20+
import WatchKit
21+
#elseif os(macOS)
1922
import Cocoa
20-
#else // iOS, tvOS
23+
#else
2124
import UIKit
2225
#endif
2326

Sources/Utils/Utils.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
//
1616

1717
import Foundation
18+
1819
#if os(watchOS)
1920
import WatchKit
21+
#elseif os(macOS)
22+
import Cocoa
2023
#else
2124
import UIKit
2225
#endif
@@ -44,6 +47,8 @@ class Utils {
4447
static var osVersion: String {
4548
#if os(watchOS)
4649
return WKInterfaceDevice.current().systemVersion
50+
#elseif os(macOS)
51+
return ProcessInfo().operatingSystemVersionString
4752
#else
4853
return UIDevice.current.systemVersion
4954
#endif
@@ -52,6 +57,8 @@ class Utils {
5257
static var deviceModel: String {
5358
#if os(watchOS)
5459
return WKInterfaceDevice.current().model
60+
#elseif os(macOS)
61+
return "N/A"
5562
#else
5663
return UIDevice.current.model
5764
#endif
@@ -105,7 +112,7 @@ class Utils {
105112
static func isStringType(_ value: Any) -> Bool {
106113
return (value is String)
107114
}
108-
115+
109116
// MARK: - NSNumber
110117

111118
static func isNSNumberBoolType(_ value: Any) -> Bool {
@@ -188,4 +195,12 @@ class Utils {
188195
}
189196
return "Invalid conditions format."
190197
}
198+
199+
// valid versions: 3.0, 2.1.2, 1.0.0-beta, ...
200+
// invalid versions: "mac os 10.3", ...
201+
static func isValidVersion(_ version: String) -> Bool {
202+
let comps = version.split(separator: ".")
203+
return comps.count > 1 && Int(comps.first!) != nil
204+
}
205+
191206
}

Tests/OptimizelyTests-Common/OdpEventManagerTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,8 @@ class OdpEventManagerTests: XCTestCase {
559559
XCTAssert((data["idempotence_id"] as! String).count > 3)
560560
XCTAssert((data["data_source_type"] as! String) == "sdk")
561561
XCTAssert((data["data_source"] as! String) == "swift-sdk")
562-
XCTAssert((data["data_source_version"] as! String).count > 3)
563-
XCTAssert((data["os_version"] as! String).count > 3)
562+
XCTAssert(Utils.isValidVersion(data["data_source_version"] as! String))
563+
XCTAssert(Utils.isValidVersion(data["os_version"] as! String))
564564

565565
// os-dependent
566566

0 commit comments

Comments
 (0)