diff --git a/CHANGELOG.md b/CHANGELOG.md index ef7eb4b34..b5b7f1f8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Optimizely Swift SDK Changelog ## 4.0.0-beta -April 28, 2023 +May 1, 2023 ### New Features diff --git a/Scripts/build_all.sh b/Scripts/build_all.sh index 5b7283976..f1fc8bdd0 100755 --- a/Scripts/build_all.sh +++ b/Scripts/build_all.sh @@ -32,6 +32,8 @@ main() { xcodebuild -workspace OptimizelySwiftSDK.xcworkspace -scheme OptimizelySwiftSDK-iOS -configuration Release "${action}" xcodebuild -workspace OptimizelySwiftSDK.xcworkspace -scheme OptimizelySwiftSDK-tvOS -configuration Release "${action}" + xcodebuild -workspace OptimizelySwiftSDK.xcworkspace -scheme OptimizelySwiftSDK-macOS -configuration Release "${action}" + xcodebuild -workspace OptimizelySwiftSDK.xcworkspace -scheme OptimizelySwiftSDK-watchOS -configuration Release "${action}" } main diff --git a/Scripts/run_prep.sh b/Scripts/run_prep.sh index ec1a03ff8..cf985c172 100755 --- a/Scripts/run_prep.sh +++ b/Scripts/run_prep.sh @@ -7,10 +7,6 @@ # Additionally, it needs the following environment variables: # VERSION - defined in swift.yml - -set -x - - COLOR_RESET='\033[0m' COLOR_MAGENTA='\033[0;35m' COLOR_CYAN='\033[0;36m' diff --git a/Scripts/run_release.sh b/Scripts/run_release.sh index 1a239b76d..2f284a4b1 100755 --- a/Scripts/run_release.sh +++ b/Scripts/run_release.sh @@ -8,7 +8,7 @@ set -e # COCOAPODS_TRUNK_TOKEN - should be defined in job settings so that we can `pod trunk push` function release_github { - LAST_RELEASE=$(git describe --abbrev=0 --tags) + LAST_RELEASE=$(git describe --abbrev=0 --tags --always) if [[ ${LAST_RELEASE} == "v${VERSION}" ]]; then echo "${LAST_RELEASE} tag exists already (probably created while in the current release process). Skipping..." return diff --git a/Sources/Protocols/BackgroundingCallbacks.swift b/Sources/Protocols/BackgroundingCallbacks.swift index fdfbb4550..958c20236 100644 --- a/Sources/Protocols/BackgroundingCallbacks.swift +++ b/Sources/Protocols/BackgroundingCallbacks.swift @@ -15,9 +15,12 @@ // import Foundation -#if os(macOS) + +#if os(watchOS) +import WatchKit +#elseif os(macOS) import Cocoa -#else // iOS, tvOS +#else import UIKit #endif diff --git a/Sources/Utils/Utils.swift b/Sources/Utils/Utils.swift index 60068f24a..480cf514d 100644 --- a/Sources/Utils/Utils.swift +++ b/Sources/Utils/Utils.swift @@ -15,8 +15,11 @@ // import Foundation + #if os(watchOS) import WatchKit +#elseif os(macOS) +import Cocoa #else import UIKit #endif @@ -44,6 +47,8 @@ class Utils { static var osVersion: String { #if os(watchOS) return WKInterfaceDevice.current().systemVersion + #elseif os(macOS) + return ProcessInfo().operatingSystemVersionString #else return UIDevice.current.systemVersion #endif @@ -52,6 +57,8 @@ class Utils { static var deviceModel: String { #if os(watchOS) return WKInterfaceDevice.current().model + #elseif os(macOS) + return "N/A" #else return UIDevice.current.model #endif @@ -105,7 +112,7 @@ class Utils { static func isStringType(_ value: Any) -> Bool { return (value is String) } - + // MARK: - NSNumber static func isNSNumberBoolType(_ value: Any) -> Bool { @@ -188,4 +195,12 @@ class Utils { } return "Invalid conditions format." } + + // valid versions: 3.0, 2.1.2, 1.0.0-beta, ... + // invalid versions: "mac os 10.3", ... + static func isValidVersion(_ version: String) -> Bool { + let comps = version.split(separator: ".") + return comps.count > 1 && Int(comps.first!) != nil + } + } diff --git a/Tests/OptimizelyTests-Common/OdpEventManagerTests.swift b/Tests/OptimizelyTests-Common/OdpEventManagerTests.swift index 4d4e24437..c6d16a873 100644 --- a/Tests/OptimizelyTests-Common/OdpEventManagerTests.swift +++ b/Tests/OptimizelyTests-Common/OdpEventManagerTests.swift @@ -559,8 +559,8 @@ class OdpEventManagerTests: XCTestCase { XCTAssert((data["idempotence_id"] as! String).count > 3) XCTAssert((data["data_source_type"] as! String) == "sdk") XCTAssert((data["data_source"] as! String) == "swift-sdk") - XCTAssert((data["data_source_version"] as! String).count > 3) - XCTAssert((data["os_version"] as! String).count > 3) + XCTAssert(Utils.isValidVersion(data["data_source_version"] as! String)) + XCTAssert(Utils.isValidVersion(data["os_version"] as! String)) // os-dependent