Skip to content

Commit

Permalink
Make non-optional properties non-optional
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-tomlein committed Jan 28, 2024
1 parent deb1f80 commit 904fa2d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions Sources/Core/Utils/DeviceInfoMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ class DeviceInfoMonitor {

/// Returns the current device's vendor in the form of a string.
/// - Returns: A string with vendor, i.e. "Apple Inc."
var deviceVendor: String? {
var deviceVendor: String {
return "Apple Inc."
}

/// Returns the current device's model in the form of a string.
/// - Returns: A string with device model.
var deviceModel: String? {
var deviceModel: String {
let simulatorModel = (ProcessInfo.processInfo.environment)["SIMULATOR_MODEL_IDENTIFIER"]
if simulatorModel != nil {
if let simulatorModel = simulatorModel {
return simulatorModel
}

Expand All @@ -59,7 +59,7 @@ class DeviceInfoMonitor {

/// This is to detect what the version of mobile OS of the current device.
/// - Returns: The current device's OS version type as a string.
var osVersion: String? {
var osVersion: String {
#if os(iOS) || os(tvOS) || os(visionOS)
return UIDevice.current.systemVersion
#elseif os(watchOS)
Expand All @@ -78,7 +78,7 @@ class DeviceInfoMonitor {
#endif
}

var osType: String? {
var osType: String {
#if os(iOS)
return "ios"
#elseif os(tvOS)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Snowplow/Configurations/TrackerConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public class TrackerConfiguration: SerializableConfiguration, TrackerConfigurati
public var advertisingIdentifierRetriever: (() -> UUID?)? {
get { return platformContextRetriever?.appleIdfa }
set {
if var retriever = platformContextRetriever {
if let retriever = platformContextRetriever {
retriever.appleIdfa = newValue
} else {
platformContextRetriever = PlatformContextRetriever(appleIdfa: newValue)
Expand Down
16 changes: 8 additions & 8 deletions Sources/Snowplow/Tracker/PlaformContextRetriever.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ import Foundation
public class PlatformContextRetriever {

/// Operating system type (e.g., ios, tvos, watchos, osx, android)
public var osType: (() -> String?)? = nil
public var osType: (() -> String)? = nil

/// The current version of the operating system
public var osVersion: (() -> String?)? = nil
public var osVersion: (() -> String)? = nil

/// The manufacturer of the product/hardware
public var deviceVendor: (() -> String?)? = nil
public var deviceVendor: (() -> String)? = nil

/// The end-user-visible name for the end product
public var deviceModel: (() -> String?)? = nil
public var deviceModel: (() -> String)? = nil

/// The carrier of the SIM inserted in the device
public var carrier: (() -> String?)? = nil
Expand Down Expand Up @@ -98,10 +98,10 @@ public class PlatformContextRetriever {
/// - scale: Scale factor used to convert logical coordinates to device coordinates of the screen (uses UIScreen.scale on iOS)
/// - language: System language currently used on the device (ISO 639)
public init(
osType: (() -> String?)? = nil,
osVersion: (() -> String?)? = nil,
deviceVendor: (() -> String?)? = nil,
deviceModel: (() -> String?)? = nil,
osType: (() -> String)? = nil,
osVersion: (() -> String)? = nil,
deviceVendor: (() -> String)? = nil,
deviceModel: (() -> String)? = nil,
carrier: (() -> String?)? = nil,
networkType: (() -> String?)? = nil,
networkTechnology: (() -> String?)? = nil,
Expand Down
8 changes: 4 additions & 4 deletions Tests/Utils/MockDeviceInfoMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ class MockDeviceInfoMonitor: DeviceInfoMonitor {
return customAppleIdfv
}

override var deviceVendor: String? {
override var deviceVendor: String {
increaseMethodAccessCount("deviceVendor")
return "Apple Inc."
}

override var deviceModel: String? {
override var deviceModel: String {
increaseMethodAccessCount("deviceModel")
return "deviceModel"
}

override var osVersion: String? {
override var osVersion: String {
increaseMethodAccessCount("osVersion")
return "13.0.0"
}

override var osType: String? {
override var osType: String {
increaseMethodAccessCount("osType")
return "ios"
}
Expand Down

0 comments on commit 904fa2d

Please sign in to comment.