From c4782742bafce2f0e24682bde1fe1aed26b98875 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Fri, 1 Mar 2024 12:02:11 +0000 Subject: [PATCH 01/16] Correct FPS for VisionOS --- DatadogRUM/Sources/RUMVitals/VitalRefreshRateReader.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DatadogRUM/Sources/RUMVitals/VitalRefreshRateReader.swift b/DatadogRUM/Sources/RUMVitals/VitalRefreshRateReader.swift index 5ee6ee52af..e69b3c9380 100644 --- a/DatadogRUM/Sources/RUMVitals/VitalRefreshRateReader.swift +++ b/DatadogRUM/Sources/RUMVitals/VitalRefreshRateReader.swift @@ -172,7 +172,9 @@ extension FrameInfoProvider { extension CADisplayLink: FrameInfoProvider { var maximumDeviceFramesPerSecond: Int { #if swift(>=5.9) && os(visionOS) - 120 + // Hardcoded as for now there's no good way of extracting maximum FPS on VisionOS + // https://developer.apple.com/documentation/visionos/analyzing-the-performance-of-your-visionos-app/ + 90 #else UIScreen.main.maximumFramesPerSecond #endif From bd29f613798aa243971875516be3b4d041c594bb Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Fri, 1 Mar 2024 12:46:11 +0000 Subject: [PATCH 02/16] Changes to support macOS logs --- DatadogCore/Private/ObjcAppLaunchHandler.m | 2 ++ .../Private/include/ObjcAppLaunchHandler.h | 2 ++ .../Core/Context/LaunchTimePublisher.swift | 2 ++ .../Core/Context/LowPowerModePublisher.swift | 9 ++++- .../NetworkConnectionInfoPublisher.swift | 12 ++++--- DatadogCore/Sources/Core/DatadogCore.swift | 5 ++- .../Sources/Core/Storage/Files/File.swift | 2 +- .../Sources/Core/Upload/FeatureUpload.swift | 2 +- .../Sources/Context/DeviceInfo.swift | 35 +++++++++++++++++-- DatadogInternal/Sources/DD.swift | 4 +-- .../URLSession/URLSessionTask+Tracking.swift | 2 +- .../URLSessionTaskInterception.swift | 2 +- Package.swift | 3 +- 13 files changed, 67 insertions(+), 15 deletions(-) diff --git a/DatadogCore/Private/ObjcAppLaunchHandler.m b/DatadogCore/Private/ObjcAppLaunchHandler.m index 2e66e94146..5d075765d5 100644 --- a/DatadogCore/Private/ObjcAppLaunchHandler.m +++ b/DatadogCore/Private/ObjcAppLaunchHandler.m @@ -4,6 +4,7 @@ * Copyright 2019-Present Datadog, Inc. */ +#if TARGET_OS_IPHONE #import #import #import @@ -128,3 +129,4 @@ int processStartTimeIntervalSinceReferenceDate(NSTimeInterval *timeInterval) { *timeInterval = processStartTime - kCFAbsoluteTimeIntervalSince1970; return res; } +#endif diff --git a/DatadogCore/Private/include/ObjcAppLaunchHandler.h b/DatadogCore/Private/include/ObjcAppLaunchHandler.h index cba4edab14..103fc42621 100644 --- a/DatadogCore/Private/include/ObjcAppLaunchHandler.h +++ b/DatadogCore/Private/include/ObjcAppLaunchHandler.h @@ -4,6 +4,7 @@ * Copyright 2019-Present Datadog, Inc. */ +#if TARGET_OS_IPHONE #import NS_ASSUME_NONNULL_BEGIN @@ -46,3 +47,4 @@ typedef void (^UIApplicationDidBecomeActiveCallback) (NSTimeInterval); @end NS_ASSUME_NONNULL_END +#endif diff --git a/DatadogCore/Sources/Core/Context/LaunchTimePublisher.swift b/DatadogCore/Sources/Core/Context/LaunchTimePublisher.swift index 58c8bd5a93..26b860049c 100644 --- a/DatadogCore/Sources/Core/Context/LaunchTimePublisher.swift +++ b/DatadogCore/Sources/Core/Context/LaunchTimePublisher.swift @@ -4,6 +4,7 @@ * Copyright 2019-Present Datadog, Inc. */ +#if !os(macOS) import Foundation import DatadogInternal @@ -42,3 +43,4 @@ internal struct LaunchTimePublisher: ContextValuePublisher { AppLaunchHandler.shared.setApplicationDidBecomeActiveCallback { _ in } } } +#endif diff --git a/DatadogCore/Sources/Core/Context/LowPowerModePublisher.swift b/DatadogCore/Sources/Core/Context/LowPowerModePublisher.swift index 11168138a3..cab1a9fcfb 100644 --- a/DatadogCore/Sources/Core/Context/LowPowerModePublisher.swift +++ b/DatadogCore/Sources/Core/Context/LowPowerModePublisher.swift @@ -25,11 +25,18 @@ internal final class LowPowerModePublisher: ContextValuePublisher { processInfo: ProcessInfo = .processInfo, notificationCenter: NotificationCenter = .default ) { - self.initialValue = processInfo.isLowPowerModeEnabled + if #available(macOS 12.0, *) { + self.initialValue = processInfo.isLowPowerModeEnabled + } else { + self.initialValue = false + } self.notificationCenter = notificationCenter } func publish(to receiver: @escaping ContextValueReceiver) { + guard #available(macOS 12.0, *) else { + return + } self.observer = notificationCenter .addObserver( forName: .NSProcessInfoPowerStateDidChange, diff --git a/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift b/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift index b24fd3df1e..25c17cc6dd 100644 --- a/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift +++ b/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift @@ -20,7 +20,7 @@ import Network /// We found the pulling model to not be thread-safe: accessing `currentPath` properties lead to occasional crashes. /// The `ThreadSafeNWPathMonitor` listens to path updates and synchonizes the values on `.current` property. /// This adds the necessary thread-safety and keeps the convenience of pulling. -@available(iOS 12, tvOS 12, *) +@available(iOS 12, tvOS 12, macOS 10.15, *) internal struct NWPathMonitorPublisher: ContextValuePublisher { private static let defaultQueue = DispatchQueue( label: "com.datadoghq.nw-path-monitor-publisher", @@ -56,7 +56,7 @@ internal struct NWPathMonitorPublisher: ContextValuePublisher { } extension NetworkConnectionInfo { - @available(iOS 12, tvOS 12, *) + @available(iOS 12, tvOS 12, macOS 10.15, *) init(_ path: NWPath) { self.init( reachability: NetworkConnectionInfo.Reachability(path.status), @@ -75,7 +75,7 @@ extension NetworkConnectionInfo { } extension NetworkConnectionInfo.Reachability { - @available(iOS 12, tvOS 12, *) + @available(iOS 12, tvOS 12, macOS 10.14, *) init(_ status: NWPath.Status) { switch status { case .satisfied: self = .yes @@ -87,7 +87,7 @@ extension NetworkConnectionInfo.Reachability { } extension NetworkConnectionInfo.Interface { - @available(iOS 12, tvOS 12, *) + @available(iOS 12, tvOS 12, macOS 10.14, *) init(_ interface: NWInterface.InterfaceType) { switch interface { case .wifi: self = .wifi @@ -152,9 +152,13 @@ extension NetworkConnectionInfo.Reachability { extension NetworkConnectionInfo.Interface { @available(iOS 2.0, macCatalyst 13.0, *) init?(_ flags: SCNetworkReachabilityFlags?) { + #if os(iOS) || os(Catalyst) guard let flags = flags, flags.contains(.isWWAN) else { return nil } self = .cellular + #else + self = .other + #endif } } diff --git a/DatadogCore/Sources/Core/DatadogCore.swift b/DatadogCore/Sources/Core/DatadogCore.swift index 27f801e3af..42a11087ff 100644 --- a/DatadogCore/Sources/Core/DatadogCore.swift +++ b/DatadogCore/Sources/Core/DatadogCore.swift @@ -417,9 +417,12 @@ extension DatadogContextProvider { self.init(context: context) subscribe(\.serverTimeOffset, to: ServerOffsetPublisher(provider: serverDateProvider)) + + #if !os(macOS) subscribe(\.launchTime, to: LaunchTimePublisher()) + #endif - if #available(iOS 12, tvOS 12, *) { + if #available(iOS 12, tvOS 12, macOS 10.15, *) { subscribe(\.networkConnectionInfo, to: NWPathMonitorPublisher()) } else { assign(reader: SCNetworkReachabilityReader(), to: \.networkConnectionInfo) diff --git a/DatadogCore/Sources/Core/Storage/Files/File.swift b/DatadogCore/Sources/Core/Storage/Files/File.swift index 0dce3b8f2a..c6eca10d00 100644 --- a/DatadogCore/Sources/Core/Storage/Files/File.swift +++ b/DatadogCore/Sources/Core/Storage/Files/File.swift @@ -70,7 +70,7 @@ internal struct File: WritableFile, ReadableFile { ``` This is fixed in iOS 14/Xcode 12 */ - if #available(iOS 13.4, tvOS 13.4, *) { + if #available(iOS 13.4, tvOS 13.4, macOS 10.15.4, *) { defer { try? fileHandle.close() } try fileHandle.seekToEnd() try fileHandle.write(contentsOf: data) diff --git a/DatadogCore/Sources/Core/Upload/FeatureUpload.swift b/DatadogCore/Sources/Core/Upload/FeatureUpload.swift index 1234ab9c2c..6e86010343 100644 --- a/DatadogCore/Sources/Core/Upload/FeatureUpload.swift +++ b/DatadogCore/Sources/Core/Upload/FeatureUpload.swift @@ -38,7 +38,7 @@ internal struct FeatureUpload { ? UIKitBackgroundTaskCoordinator() : nil #else - let backgroundTaskCoordinator = nil + let backgroundTaskCoordinator: BackgroundTaskCoordinator? = nil #endif self.init( diff --git a/DatadogInternal/Sources/Context/DeviceInfo.swift b/DatadogInternal/Sources/Context/DeviceInfo.swift index dc3c62ae45..f729df37a6 100644 --- a/DatadogInternal/Sources/Context/DeviceInfo.swift +++ b/DatadogInternal/Sources/Context/DeviceInfo.swift @@ -49,10 +49,10 @@ public struct DeviceInfo: Codable, Equatable, PassthroughAnyCodable { } } -#if canImport(UIKit) +import MachO +#if canImport(UIKit) import UIKit -import MachO extension DeviceInfo { /// Creates device info based on UIKit description. @@ -68,6 +68,7 @@ extension DeviceInfo { if let archInfo = NXGetLocalArchInfo()?.pointee { architecture = String(utf8String: archInfo.name) ?? "unknown" } + Host.current().name let build = try? Sysctl.osVersion() @@ -96,4 +97,34 @@ extension DeviceInfo { #endif } } +#else +/// Creates device info based on Host description. +/// +/// - Parameters: +/// - processInfo: The current process information. +/// - device: The `Host` description. +extension DeviceInfo { + public init( + processInfo: ProcessInfo = .processInfo + ) { + var architecture = "unknown" + if let archInfo = NXGetLocalArchInfo()?.pointee { + architecture = String(utf8String: archInfo.name) ?? "unknown" + } + Host.current().name + + let build = (try? Sysctl.osVersion()) ?? "" + let model = (try? Sysctl.model()) ?? "" + let systemVersion = processInfo.operatingSystemVersion + + self.init( + name: model.components(separatedBy: CharacterSet.letters.inverted).joined(), + model: model, + osName: "macOS", + osVersion: "\(systemVersion.majorVersion).\(systemVersion.minorVersion).\(systemVersion.patchVersion)", + osBuildNumber: build, + architecture: architecture + ) + } +} #endif diff --git a/DatadogInternal/Sources/DD.swift b/DatadogInternal/Sources/DD.swift index fd10e21633..3e68e1b1d4 100644 --- a/DatadogInternal/Sources/DD.swift +++ b/DatadogInternal/Sources/DD.swift @@ -32,7 +32,7 @@ import OSLog /// Function printing `String` content to console. public var consolePrint: (String, CoreLoggerLevel) -> Void = { message, level in #if canImport(OSLog) - if #available(iOS 14.0, tvOS 14.0, *) { + if #available(iOS 14.0, tvOS 14.0, macOS 11.0, *) { switch level { case .debug: Logger.datadog.debug("\(message, privacy: .private)") case .warn: Logger.datadog.warning("\(message, privacy: .private)") @@ -48,7 +48,7 @@ public var consolePrint: (String, CoreLoggerLevel) -> Void = { message, level in } #if canImport(OSLog) -@available(iOS 14.0, tvOS 14.0, *) +@available(iOS 14.0, tvOS 14.0, macOS 11.0, *) extension Logger { static let datadog = Logger(subsystem: "dd-sdk-ios", category: "DatadogInternal") } diff --git a/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTask+Tracking.swift b/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTask+Tracking.swift index da1a44f42c..c97085867d 100644 --- a/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTask+Tracking.swift +++ b/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTask+Tracking.swift @@ -21,7 +21,7 @@ extension DatadogExtension where ExtendedType: URLSessionTask { /// Returns the delegate instance the task is reporting to. var delegate: URLSessionDelegate? { - if #available(iOS 15.0, tvOS 15.0, *), let delegate = type.delegate { + if #available(iOS 15.0, tvOS 15.0, macOS 12.0, *), let delegate = type.delegate { return delegate } diff --git a/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTaskInterception.swift b/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTaskInterception.swift index 609bfc1996..62592acd36 100644 --- a/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTaskInterception.swift +++ b/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTaskInterception.swift @@ -255,7 +255,7 @@ extension ResourceMetrics { download = DateInterval(start: downloadStart, end: downloadEnd) } - if #available(iOS 13.0, tvOS 13, *) { + if #available(iOS 13.0, tvOS 13, macOS 10.15, *) { responseSize = mainTransaction.countOfResponseBodyBytesAfterDecoding } } diff --git a/Package.swift b/Package.swift index 5dc10e2db5..87c819d351 100644 --- a/Package.swift +++ b/Package.swift @@ -7,7 +7,8 @@ let package = Package( name: "Datadog", platforms: [ .iOS(.v11), - .tvOS(.v11) + .tvOS(.v11), + .macOS(.v12) ], products: [ .library( From f13329ce23e23b82399d3b3b92759a0ff8fab00e Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Fri, 1 Mar 2024 12:53:26 +0000 Subject: [PATCH 03/16] Clean up --- DatadogInternal/Sources/Context/DeviceInfo.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DatadogInternal/Sources/Context/DeviceInfo.swift b/DatadogInternal/Sources/Context/DeviceInfo.swift index f729df37a6..2cba44e6ea 100644 --- a/DatadogInternal/Sources/Context/DeviceInfo.swift +++ b/DatadogInternal/Sources/Context/DeviceInfo.swift @@ -68,7 +68,7 @@ extension DeviceInfo { if let archInfo = NXGetLocalArchInfo()?.pointee { architecture = String(utf8String: archInfo.name) ?? "unknown" } - Host.current().name + let build = try? Sysctl.osVersion() From 26385f1acb54afd7f16aa29f1e1795140f2c3ef4 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Fri, 22 Mar 2024 13:03:53 +0000 Subject: [PATCH 04/16] Fix compilation issue on ios --- DatadogCore/Private/ObjcAppLaunchHandler.m | 10 ++++++---- DatadogCore/Private/include/ObjcAppLaunchHandler.h | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/DatadogCore/Private/ObjcAppLaunchHandler.m b/DatadogCore/Private/ObjcAppLaunchHandler.m index 5d075765d5..0f60b47d31 100644 --- a/DatadogCore/Private/ObjcAppLaunchHandler.m +++ b/DatadogCore/Private/ObjcAppLaunchHandler.m @@ -4,13 +4,15 @@ * Copyright 2019-Present Datadog, Inc. */ -#if TARGET_OS_IPHONE -#import #import #import #import "ObjcAppLaunchHandler.h" +#if TARGET_OS_IPHONE +#import +#endif + // A very long application launch time is most-likely the result of a pre-warmed process. // We consider 30s as a threshold for pre-warm detection. #define COLD_START_TIME_THRESHOLD 30 @@ -40,7 +42,7 @@ + (void)load { // This is called at the `DatadogPrivate` load time, keep the work minimal _shared = [[self alloc] initWithProcessInfo:NSProcessInfo.processInfo loadTime:CFAbsoluteTimeGetCurrent()]; - +#if TARGET_OS_IPHONE NSNotificationCenter * __weak center = NSNotificationCenter.defaultCenter; id __block __unused token = [center addObserverForName:UIApplicationDidBecomeActiveNotification object:nil @@ -56,6 +58,7 @@ + (void)load { [center removeObserver:token]; token = nil; }]; +#endif } + (__dd_private_AppLaunchHandler *)shared { @@ -129,4 +132,3 @@ int processStartTimeIntervalSinceReferenceDate(NSTimeInterval *timeInterval) { *timeInterval = processStartTime - kCFAbsoluteTimeIntervalSince1970; return res; } -#endif diff --git a/DatadogCore/Private/include/ObjcAppLaunchHandler.h b/DatadogCore/Private/include/ObjcAppLaunchHandler.h index 103fc42621..cba4edab14 100644 --- a/DatadogCore/Private/include/ObjcAppLaunchHandler.h +++ b/DatadogCore/Private/include/ObjcAppLaunchHandler.h @@ -4,7 +4,6 @@ * Copyright 2019-Present Datadog, Inc. */ -#if TARGET_OS_IPHONE #import NS_ASSUME_NONNULL_BEGIN @@ -47,4 +46,3 @@ typedef void (^UIApplicationDidBecomeActiveCallback) (NSTimeInterval); @end NS_ASSUME_NONNULL_END -#endif From d4d5c99194a2bd118a6596214cbd0e200c78cb73 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Tue, 2 Apr 2024 12:50:14 +0100 Subject: [PATCH 05/16] Run linter --- DatadogInternal/Sources/Context/DeviceInfo.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/DatadogInternal/Sources/Context/DeviceInfo.swift b/DatadogInternal/Sources/Context/DeviceInfo.swift index 2cba44e6ea..ceec8d4328 100644 --- a/DatadogInternal/Sources/Context/DeviceInfo.swift +++ b/DatadogInternal/Sources/Context/DeviceInfo.swift @@ -69,7 +69,6 @@ extension DeviceInfo { architecture = String(utf8String: archInfo.name) ?? "unknown" } - let build = try? Sysctl.osVersion() #if !targetEnvironment(simulator) From f66af65a9e6e543d9fc596091ac5d5b1e01eae56 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Tue, 2 Apr 2024 13:33:32 +0100 Subject: [PATCH 06/16] PR fixes --- .../Context/NetworkConnectionInfoPublisher.swift | 2 +- Package.swift | 2 +- SUPPORTED-VERSIONS.md | 15 ++++++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift b/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift index 25c17cc6dd..5b6a5b8cd7 100644 --- a/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift +++ b/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift @@ -152,7 +152,7 @@ extension NetworkConnectionInfo.Reachability { extension NetworkConnectionInfo.Interface { @available(iOS 2.0, macCatalyst 13.0, *) init?(_ flags: SCNetworkReachabilityFlags?) { - #if os(iOS) || os(Catalyst) + #if os(iOS) guard let flags = flags, flags.contains(.isWWAN) else { return nil } diff --git a/Package.swift b/Package.swift index 87c819d351..142869f629 100644 --- a/Package.swift +++ b/Package.swift @@ -8,7 +8,7 @@ let package = Package( platforms: [ .iOS(.v11), .tvOS(.v11), - .macOS(.v12) + .macOS(.v10_15) ], products: [ .library( diff --git a/SUPPORTED-VERSIONS.md b/SUPPORTED-VERSIONS.md index 69d08a31e2..211a6ff3ac 100644 --- a/SUPPORTED-VERSIONS.md +++ b/SUPPORTED-VERSIONS.md @@ -5,13 +5,18 @@ | **iOS** | ✅ | `11+` | | **tvOS** | ✅ | `11+` | | **iPadOS** | ✅ | `11+` | -| **VisionOS** | ⚠️ | `1.1+` | +| **visionOS** | ⚠️ | `1.0+` | +| **macOS** | ⚠️ | `10.15+` | | **watchOS**| ❌ | `n/a` | -| **macOS** | ❌ | `n/a` | | **Linux** | ❌ | `n/a` | -## VisionOS -VisionOS is not officially supported by Datadog SDK. Some features may not be fully functional. +## visionOS + +The visionOS is not officially supported by Datadog SDK. Some features may not be fully functional. + +## macOS + +The macOS is not officially supported by Datadog SDK. Some features may not be fully functional. Note that `RUM`, which heavily depends on `UIKit` does not build on macOS. ## Xcode @@ -52,4 +57,4 @@ We support Catalyst in build mode only, which means that macOS target will build ## Dependencies The Datadog SDK depends on the following third-party library: -- [PLCrashReporter](https://github.com/microsoft/plcrashreporter) 1.11.1 \ No newline at end of file +- [PLCrashReporter](https://github.com/microsoft/plcrashreporter) 1.11.1 From 7562259f25f61065a6b2afcb841fa3b23668f1a6 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Tue, 2 Apr 2024 14:04:11 +0100 Subject: [PATCH 07/16] Fix test --- .../Sources/Core/Context/NetworkConnectionInfoPublisher.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift b/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift index 5b6a5b8cd7..4b7b61414b 100644 --- a/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift +++ b/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift @@ -152,7 +152,7 @@ extension NetworkConnectionInfo.Reachability { extension NetworkConnectionInfo.Interface { @available(iOS 2.0, macCatalyst 13.0, *) init?(_ flags: SCNetworkReachabilityFlags?) { - #if os(iOS) + #if os(iOS) || os(tvOS) guard let flags = flags, flags.contains(.isWWAN) else { return nil } From b5a4a516c501d3a22c383389022be23f59bb02f4 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Thu, 18 Apr 2024 11:01:14 +0100 Subject: [PATCH 08/16] PR Fixes --- DatadogCore/Private/ObjcAppLaunchHandler.m | 4 ++-- DatadogCore/Sources/Datadog.swift | 6 +++++- SUPPORTED-VERSIONS.md | 8 ++++---- bitrise.yml | 12 ++++++++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/DatadogCore/Private/ObjcAppLaunchHandler.m b/DatadogCore/Private/ObjcAppLaunchHandler.m index 0f60b47d31..1b2a2dd2dd 100644 --- a/DatadogCore/Private/ObjcAppLaunchHandler.m +++ b/DatadogCore/Private/ObjcAppLaunchHandler.m @@ -9,7 +9,7 @@ #import "ObjcAppLaunchHandler.h" -#if TARGET_OS_IPHONE +#if TARGET_OS_IOS || TARGET_OS_TV #import #endif @@ -42,7 +42,7 @@ + (void)load { // This is called at the `DatadogPrivate` load time, keep the work minimal _shared = [[self alloc] initWithProcessInfo:NSProcessInfo.processInfo loadTime:CFAbsoluteTimeGetCurrent()]; -#if TARGET_OS_IPHONE +#if TARGET_OS_IOS || TARGET_OS_TV NSNotificationCenter * __weak center = NSNotificationCenter.defaultCenter; id __block __unused token = [center addObserverForName:UIApplicationDidBecomeActiveNotification object:nil diff --git a/DatadogCore/Sources/Datadog.swift b/DatadogCore/Sources/Datadog.swift index 272f53d588..3813e98f12 100644 --- a/DatadogCore/Sources/Datadog.swift +++ b/DatadogCore/Sources/Datadog.swift @@ -365,8 +365,12 @@ public enum Datadog { consolePrint("⚠️ Catalyst is not officially supported by Datadog SDK: some features may NOT be functional!", .warn) #endif + #if os(macOS) + consolePrint("⚠️ macOS is not officially supported by Datadog SDK: some features may NOT be functional!", .warn) + #endif + #if swift(>=5.9) && os(visionOS) - consolePrint("⚠️ VisionOS is not officially supported by Datadog SDK: some features may NOT be functional!", .warn) + consolePrint("⚠️ visionOS is not officially supported by Datadog SDK: some features may NOT be functional!", .warn) #endif do { diff --git a/SUPPORTED-VERSIONS.md b/SUPPORTED-VERSIONS.md index 211a6ff3ac..e259c2584a 100644 --- a/SUPPORTED-VERSIONS.md +++ b/SUPPORTED-VERSIONS.md @@ -10,13 +10,13 @@ | **watchOS**| ❌ | `n/a` | | **Linux** | ❌ | `n/a` | -## visionOS +## VisionOS -The visionOS is not officially supported by Datadog SDK. Some features may not be fully functional. +VisionOS is not officially supported by Datadog SDK. Some features may not be fully functional. Note that `CrashReporting` is not supported on VisionOS, due to lack of support on the [PLCrashReporter side](https://github.com/microsoft/plcrashreporter/issues/288). -## macOS +## MacOS -The macOS is not officially supported by Datadog SDK. Some features may not be fully functional. Note that `RUM`, which heavily depends on `UIKit` does not build on macOS. +MacOS is not officially supported by Datadog SDK. Some features may not be fully functional. Note that `RUM`, which heavily depends on `UIKit` does not build on macOS. ## Xcode diff --git a/bitrise.yml b/bitrise.yml index e6a5f01ac1..718c34f719 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -360,6 +360,18 @@ workflows: -project "$BITRISE_SOURCE_DIR/dependency-manager-tests/spm/SPMProject.xcodeproj" \ -destination "platform=macOS,variant=Mac Catalyst" \ | xcpretty + - script: + title: Check macOS compatibility (build SPMProject for macOS) + run_if: '{{enveq "DD_RUN_SMOKE_TESTS" "1"}}' + inputs: + - content: |- + #!/usr/bin/env bash + set -euxo pipefail + + xcodebuild build -scheme "App macOS" \ + -project "$BITRISE_SOURCE_DIR/dependency-manager-tests/spm/SPMProject.xcodeproj" \ + -destination "platform=macOS" \ + | xcpretty - xcode-test: title: Run SPMProject iOS tests run_if: '{{enveq "DD_RUN_SMOKE_TESTS" "1"}}' From 687903b1d51e628462ebd290c844a3708b3dec1f Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Thu, 18 Apr 2024 12:03:53 +0100 Subject: [PATCH 09/16] Add smoke tests for macOS --- bitrise.yml | 10 + .../spm/App macOS/App_macOS.entitlements | 2 + .../spm/App macOS/App_macOSApp.swift | 16 + .../spm/App macOS/ContentView.swift | 22 ++ .../App macOSUITests/App_macOSUITests.swift | 15 + .../spm/App/DatadogSetup.swift | 37 ++ .../spm/App/ViewController.swift | 33 +- .../SPMProject.xcodeproj.src/project.pbxproj | 330 +++++++++++++++++- .../xcshareddata/xcschemes/App macOS.xcscheme | 102 ++++++ 9 files changed, 534 insertions(+), 33 deletions(-) create mode 100644 dependency-manager-tests/spm/App macOS/App_macOS.entitlements create mode 100644 dependency-manager-tests/spm/App macOS/App_macOSApp.swift create mode 100644 dependency-manager-tests/spm/App macOS/ContentView.swift create mode 100644 dependency-manager-tests/spm/App macOSUITests/App_macOSUITests.swift create mode 100644 dependency-manager-tests/spm/App/DatadogSetup.swift create mode 100644 dependency-manager-tests/spm/SPMProject.xcodeproj.src/xcshareddata/xcschemes/App macOS.xcscheme diff --git a/bitrise.yml b/bitrise.yml index 718c34f719..7566442753 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -392,6 +392,16 @@ workflows: - cache_level: none - project_path: "$BITRISE_SOURCE_DIR/dependency-manager-tests/spm/SPMProject.xcodeproj" - xcpretty_test_options: --color --report html --output "${BITRISE_DEPLOY_DIR}/SPMProject-tvos-tests.html" + - xcode-test: + title: Run SPMProject macOS tests + run_if: '{{enveq "DD_RUN_SMOKE_TESTS" "1"}}' + inputs: + - scheme: App macOS + - destination: platform=macOS,name=macOS + - is_clean_build: 'yes' + - cache_level: none + - project_path: "$BITRISE_SOURCE_DIR/dependency-manager-tests/spm/SPMProject.xcodeproj" + - xcpretty_test_options: --color --report html --output "${BITRISE_DEPLOY_DIR}/SPMProject-macos-tests.html" - script: title: Test Carthage compatibility run_if: '{{enveq "DD_RUN_SMOKE_TESTS" "1"}}' diff --git a/dependency-manager-tests/spm/App macOS/App_macOS.entitlements b/dependency-manager-tests/spm/App macOS/App_macOS.entitlements new file mode 100644 index 0000000000..a11054c1df --- /dev/null +++ b/dependency-manager-tests/spm/App macOS/App_macOS.entitlements @@ -0,0 +1,2 @@ +com.apple.security.app-sandbox + diff --git a/dependency-manager-tests/spm/App macOS/App_macOSApp.swift b/dependency-manager-tests/spm/App macOS/App_macOSApp.swift new file mode 100644 index 0000000000..1053dd8d9c --- /dev/null +++ b/dependency-manager-tests/spm/App macOS/App_macOSApp.swift @@ -0,0 +1,16 @@ +/* +* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. +* This product includes software developed at Datadog (https://www.datadoghq.com/). +* Copyright 2019-Present Datadog, Inc. +*/ + +import SwiftUI + +@main +struct App_macOSApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +} diff --git a/dependency-manager-tests/spm/App macOS/ContentView.swift b/dependency-manager-tests/spm/App macOS/ContentView.swift new file mode 100644 index 0000000000..97bdbda50b --- /dev/null +++ b/dependency-manager-tests/spm/App macOS/ContentView.swift @@ -0,0 +1,22 @@ +/* +* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. +* This product includes software developed at Datadog (https://www.datadoghq.com/). +* Copyright 2019-Present Datadog, Inc. +*/ + +import SwiftUI + +struct ContentView: View { + var body: some View { + VStack { + Image(systemName: "globe") + .imageScale(.large) + Text("Testing...") + } + .padding() + } + + init() { + DatadogSetup.initialize() + } +} diff --git a/dependency-manager-tests/spm/App macOSUITests/App_macOSUITests.swift b/dependency-manager-tests/spm/App macOSUITests/App_macOSUITests.swift new file mode 100644 index 0000000000..b0eacadf1c --- /dev/null +++ b/dependency-manager-tests/spm/App macOSUITests/App_macOSUITests.swift @@ -0,0 +1,15 @@ +/* +* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. +* This product includes software developed at Datadog (https://www.datadoghq.com/). +* Copyright 2019-Present Datadog, Inc. +*/ + +import XCTest + +final class App_macOSUITests: XCTestCase { + func testExample() throws { + let app = XCUIApplication() + app.launch() + XCTAssert(app.staticTexts["Testing..."].exists) + } +} diff --git a/dependency-manager-tests/spm/App/DatadogSetup.swift b/dependency-manager-tests/spm/App/DatadogSetup.swift new file mode 100644 index 0000000000..899fc5fc98 --- /dev/null +++ b/dependency-manager-tests/spm/App/DatadogSetup.swift @@ -0,0 +1,37 @@ +/* +* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. +* This product includes software developed at Datadog (https://www.datadoghq.com/). +* Copyright 2019-Present Datadog, Inc. +*/ + +import DatadogCore +import DatadogLogs +import DatadogTrace +import DatadogCrashReporting + +enum DatadogSetup { + static var logger: LoggerProtocol? + static func initialize() { + Datadog.initialize( + with: Datadog.Configuration(clientToken: "abc", env: "tests"), + trackingConsent: .granted + ) + + Logs.enable() + + CrashReporting.enable() + + logger = Logger.create( + with: Logger.Configuration( + remoteSampleRate: 0, + consoleLogFormat: .short + ) + ) + + // Trace APIs must be visible: + Trace.enable() + + logger?.info("It works") + _ = Tracer.shared().startSpan(operationName: "this too") + } +} diff --git a/dependency-manager-tests/spm/App/ViewController.swift b/dependency-manager-tests/spm/App/ViewController.swift index a1b1e258c4..5e1a17c4d5 100644 --- a/dependency-manager-tests/spm/App/ViewController.swift +++ b/dependency-manager-tests/spm/App/ViewController.swift @@ -5,46 +5,19 @@ */ import UIKit -import DatadogCore -import DatadogLogs -import DatadogTrace import DatadogRUM -import DatadogCrashReporting -import DatadogSessionReplay // it should compile for iOS and tvOS, but APIs are only available on iOS import DatadogObjc +import DatadogSessionReplay // it should compile for iOS and tvOS, but APIs are only available on iOS internal class ViewController: UIViewController { - private var logger: LoggerProtocol! // swiftlint:disable:this implicitly_unwrapped_optional - override func viewDidLoad() { super.viewDidLoad() - - Datadog.initialize( - with: Datadog.Configuration(clientToken: "abc", env: "tests"), - trackingConsent: .granted - ) - - Logs.enable() - - CrashReporting.enable() - - self.logger = Logger.create( - with: Logger.Configuration( - remoteSampleRate: 0, - consoleLogFormat: .short - ) - ) + DatadogSetup.initialize() // RUM APIs must be visible: RUM.enable(with: .init(applicationID: "app-id")) RUMMonitor.shared().startView(viewController: self) - - // Trace APIs must be visible: - Trace.enable() - - logger.info("It works") - _ = Tracer.shared().startSpan(operationName: "this too") - + #if os(iOS) // Session Replay API must be visible: SessionReplay.enable(with: .init(replaySampleRate: 0)) diff --git a/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj b/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj index f4720f51a7..2a576280a1 100644 --- a/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj +++ b/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj @@ -14,6 +14,17 @@ 61C363F124374D6100C4D4E6 /* AppTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61C363F024374D6100C4D4E6 /* AppTests.swift */; }; 61C363FC24374D6100C4D4E6 /* AppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61C363FB24374D6100C4D4E6 /* AppUITests.swift */; }; 9E73374026B0123500917C24 /* DatadogCrashReporting in Frameworks */ = {isa = PBXBuildFile; productRef = 9E73373F26B0123500917C24 /* DatadogCrashReporting */; }; + A71398892BD127790050A54E /* App_macOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71398882BD127790050A54E /* App_macOSApp.swift */; }; + A713988B2BD127790050A54E /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A713988A2BD127790050A54E /* ContentView.swift */; }; + A71398A52BD1277A0050A54E /* App_macOSUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71398A42BD1277A0050A54E /* App_macOSUITests.swift */; }; + A71398B22BD12B6D0050A54E /* DatadogSetup.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71398B12BD12B6D0050A54E /* DatadogSetup.swift */; }; + A71398B32BD12B6D0050A54E /* DatadogSetup.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71398B12BD12B6D0050A54E /* DatadogSetup.swift */; }; + A71398B42BD12B6D0050A54E /* DatadogSetup.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71398B12BD12B6D0050A54E /* DatadogSetup.swift */; }; + A71398B62BD12BC60050A54E /* DatadogCore in Frameworks */ = {isa = PBXBuildFile; productRef = A71398B52BD12BC60050A54E /* DatadogCore */; }; + A71398B82BD12BC60050A54E /* DatadogCrashReporting in Frameworks */ = {isa = PBXBuildFile; productRef = A71398B72BD12BC60050A54E /* DatadogCrashReporting */; }; + A71398BA2BD12BC60050A54E /* DatadogLogs in Frameworks */ = {isa = PBXBuildFile; productRef = A71398B92BD12BC60050A54E /* DatadogLogs */; }; + A71398BC2BD12BC60050A54E /* DatadogTrace in Frameworks */ = {isa = PBXBuildFile; productRef = A71398BB2BD12BC60050A54E /* DatadogTrace */; }; + A71398BE2BD12BC60050A54E /* DatadogWebViewTracking in Frameworks */ = {isa = PBXBuildFile; productRef = A71398BD2BD12BC60050A54E /* DatadogWebViewTracking */; }; D22919312B76589B00C38A18 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = D22919302B76589B00C38A18 /* PrivacyInfo.xcprivacy */; }; D22919322B76589B00C38A18 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = D22919302B76589B00C38A18 /* PrivacyInfo.xcprivacy */; }; D2344E1F29ACDE61007F5BD2 /* DatadogLogs in Frameworks */ = {isa = PBXBuildFile; productRef = D2344E1E29ACDE61007F5BD2 /* DatadogLogs */; }; @@ -50,6 +61,13 @@ remoteGlobalIDString = 61C363D524374D5F00C4D4E6; remoteInfo = SPMProject; }; + A71398A12BD1277A0050A54E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 61C363CE24374D5F00C4D4E6 /* Project object */; + proxyType = 1; + remoteGlobalIDString = A71398852BD127790050A54E; + remoteInfo = "App macOS"; + }; D23BF61827CCCE2300BB4CCD /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 61C363CE24374D5F00C4D4E6 /* Project object */; @@ -103,6 +121,13 @@ 61C363FD24374D6100C4D4E6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 61CE5FD52461D3C2005EA621 /* Datadog.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Datadog.xcconfig; sourceTree = ""; }; 61CE5FD62461D3C2005EA621 /* Datadog.local.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Datadog.local.xcconfig; sourceTree = ""; }; + A71398862BD127790050A54E /* App macOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "App macOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + A71398882BD127790050A54E /* App_macOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App_macOSApp.swift; sourceTree = ""; }; + A713988A2BD127790050A54E /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + A71398A02BD1277A0050A54E /* App macOSUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "App macOSUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + A71398A42BD1277A0050A54E /* App_macOSUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App_macOSUITests.swift; sourceTree = ""; }; + A71398B12BD12B6D0050A54E /* DatadogSetup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatadogSetup.swift; sourceTree = ""; }; + A7DFE01A2BD131D90024E5E1 /* App_macOS.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = App_macOS.entitlements; sourceTree = ""; }; D22919302B76589B00C38A18 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; D23BF5FE27CCCC3300BB4CCD /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; }; D23BF60A27CCCCF800BB4CCD /* App tvOS UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "App tvOS UITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -139,6 +164,25 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A71398832BD127790050A54E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A71398B82BD12BC60050A54E /* DatadogCrashReporting in Frameworks */, + A71398BE2BD12BC60050A54E /* DatadogWebViewTracking in Frameworks */, + A71398BA2BD12BC60050A54E /* DatadogLogs in Frameworks */, + A71398B62BD12BC60050A54E /* DatadogCore in Frameworks */, + A71398BC2BD12BC60050A54E /* DatadogTrace in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A713989D2BD1277A0050A54E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; D23BF5F627CCCC3300BB4CCD /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -176,6 +220,8 @@ 61C363D824374D5F00C4D4E6 /* App */, 61C363EF24374D6100C4D4E6 /* AppTests */, 61C363FA24374D6100C4D4E6 /* AppUITests */, + A71398872BD127790050A54E /* App macOS */, + A71398A32BD1277A0050A54E /* App macOSUITests */, 61C363D724374D5F00C4D4E6 /* Products */, 9EC32C6024E596C20063BCCE /* Frameworks */, ); @@ -190,6 +236,8 @@ D23BF5FE27CCCC3300BB4CCD /* App.app */, D23BF60A27CCCCF800BB4CCD /* App tvOS UITests.xctest */, D23BF61627CCCD5700BB4CCD /* App tvOS Tests.xctest */, + A71398862BD127790050A54E /* App macOS.app */, + A71398A02BD1277A0050A54E /* App macOSUITests.xctest */, ); name = Products; sourceTree = ""; @@ -202,6 +250,7 @@ 61C363DD24374D5F00C4D4E6 /* ViewController.swift */, 61C363E724374D6000C4D4E6 /* Info.plist */, D22919302B76589B00C38A18 /* PrivacyInfo.xcprivacy */, + A71398B12BD12B6D0050A54E /* DatadogSetup.swift */, ); path = App; sourceTree = ""; @@ -241,6 +290,24 @@ name = Frameworks; sourceTree = ""; }; + A71398872BD127790050A54E /* App macOS */ = { + isa = PBXGroup; + children = ( + A7DFE01A2BD131D90024E5E1 /* App_macOS.entitlements */, + A71398882BD127790050A54E /* App_macOSApp.swift */, + A713988A2BD127790050A54E /* ContentView.swift */, + ); + path = "App macOS"; + sourceTree = ""; + }; + A71398A32BD1277A0050A54E /* App macOSUITests */ = { + isa = PBXGroup; + children = ( + A71398A42BD1277A0050A54E /* App_macOSUITests.swift */, + ); + path = "App macOSUITests"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -309,6 +376,48 @@ productReference = 61C363F724374D6100C4D4E6 /* App iOS UITests.xctest */; productType = "com.apple.product-type.bundle.ui-testing"; }; + A71398852BD127790050A54E /* App macOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = A71398AE2BD1277A0050A54E /* Build configuration list for PBXNativeTarget "App macOS" */; + buildPhases = ( + A71398822BD127790050A54E /* Sources */, + A71398832BD127790050A54E /* Frameworks */, + A71398842BD127790050A54E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "App macOS"; + packageProductDependencies = ( + A71398B52BD12BC60050A54E /* DatadogCore */, + A71398B72BD12BC60050A54E /* DatadogCrashReporting */, + A71398B92BD12BC60050A54E /* DatadogLogs */, + A71398BB2BD12BC60050A54E /* DatadogTrace */, + A71398BD2BD12BC60050A54E /* DatadogWebViewTracking */, + ); + productName = "App macOS"; + productReference = A71398862BD127790050A54E /* App macOS.app */; + productType = "com.apple.product-type.application"; + }; + A713989F2BD1277A0050A54E /* App macOSUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = A71398B02BD1277A0050A54E /* Build configuration list for PBXNativeTarget "App macOSUITests" */; + buildPhases = ( + A713989C2BD1277A0050A54E /* Sources */, + A713989D2BD1277A0050A54E /* Frameworks */, + A713989E2BD1277A0050A54E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + A71398A22BD1277A0050A54E /* PBXTargetDependency */, + ); + name = "App macOSUITests"; + productName = "App macOSUITests"; + productReference = A71398A02BD1277A0050A54E /* App macOSUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; D23BF5EF27CCCC3300BB4CCD /* App tvOS */ = { isa = PBXNativeTarget; buildConfigurationList = D23BF5FB27CCCC3300BB4CCD /* Build configuration list for PBXNativeTarget "App tvOS" */; @@ -378,7 +487,7 @@ 61C363CE24374D5F00C4D4E6 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 1140; + LastSwiftUpdateCheck = 1530; LastUpgradeCheck = 1310; ORGANIZATIONNAME = Datadog; TargetAttributes = { @@ -393,6 +502,13 @@ CreatedOnToolsVersion = 11.4; TestTargetID = 61C363D524374D5F00C4D4E6; }; + A71398852BD127790050A54E = { + CreatedOnToolsVersion = 15.3; + }; + A713989F2BD1277A0050A54E = { + CreatedOnToolsVersion = 15.3; + TestTargetID = A71398852BD127790050A54E; + }; D23BF60027CCCCF800BB4CCD = { TestTargetID = D23BF5EF27CCCC3300BB4CCD; }; @@ -423,6 +539,8 @@ D23BF5EF27CCCC3300BB4CCD /* App tvOS */, D23BF60C27CCCD5700BB4CCD /* App tvOS Tests */, D23BF60027CCCCF800BB4CCD /* App tvOS UITests */, + A71398852BD127790050A54E /* App macOS */, + A713989F2BD1277A0050A54E /* App macOSUITests */, ); }; /* End PBXProject section */ @@ -450,6 +568,20 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A71398842BD127790050A54E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A713989E2BD1277A0050A54E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; D23BF5F827CCCC3300BB4CCD /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -522,6 +654,7 @@ files = ( 61C363DE24374D5F00C4D4E6 /* ViewController.swift in Sources */, 61C363DA24374D5F00C4D4E6 /* AppDelegate.swift in Sources */, + A71398B22BD12B6D0050A54E /* DatadogSetup.swift in Sources */, 61C363DC24374D5F00C4D4E6 /* SceneDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -542,12 +675,31 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A71398822BD127790050A54E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A713988B2BD127790050A54E /* ContentView.swift in Sources */, + A71398892BD127790050A54E /* App_macOSApp.swift in Sources */, + A71398B42BD12B6D0050A54E /* DatadogSetup.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A713989C2BD1277A0050A54E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A71398A52BD1277A0050A54E /* App_macOSUITests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; D23BF5F227CCCC3300BB4CCD /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( D23BF5F327CCCC3300BB4CCD /* ViewController.swift in Sources */, D23BF5F427CCCC3300BB4CCD /* AppDelegate.swift in Sources */, + A71398B32BD12B6D0050A54E /* DatadogSetup.swift in Sources */, D23BF5F527CCCC3300BB4CCD /* SceneDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -581,6 +733,11 @@ target = 61C363D524374D5F00C4D4E6 /* App iOS */; targetProxy = 61C363F824374D6100C4D4E6 /* PBXContainerItemProxy */; }; + A71398A22BD1277A0050A54E /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = A71398852BD127790050A54E /* App macOS */; + targetProxy = A71398A12BD1277A0050A54E /* PBXContainerItemProxy */; + }; D23BF61927CCCE2300BB4CCD /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = D23BF5EF27CCCC3300BB4CCD /* App tvOS */; @@ -854,6 +1011,130 @@ }; name = Release; }; + A71398A82BD1277A0050A54E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_ENTITLEMENTS = "App macOS/App_macOS.entitlements"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; + CODE_SIGN_STYLE = Manual; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = ""; + DEVELOPMENT_TEAM = ""; + ENABLE_HARDENED_RUNTIME = YES; + ENABLE_PREVIEWS = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2024 Datadog. All rights reserved."; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 11; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.datadoghq.App-macOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + A71398A92BD1277A0050A54E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_ENTITLEMENTS = "App macOS/App_macOS.entitlements"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; + CODE_SIGN_STYLE = Manual; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = ""; + DEVELOPMENT_TEAM = ""; + ENABLE_HARDENED_RUNTIME = YES; + ENABLE_PREVIEWS = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2024 Datadog. All rights reserved."; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 11; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.datadoghq.App-macOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SDKROOT = macosx; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + A71398AC2BD1277A0050A54E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = ""; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 11; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.datadoghq.App-macOSUITests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TEST_TARGET_NAME = "App macOS"; + }; + name = Debug; + }; + A71398AD2BD1277A0050A54E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = ""; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 11; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.datadoghq.App-macOSUITests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SDKROOT = macosx; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TEST_TARGET_NAME = "App macOS"; + }; + name = Release; + }; D23BF5FC27CCCC3300BB4CCD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1031,6 +1312,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + A71398AE2BD1277A0050A54E /* Build configuration list for PBXNativeTarget "App macOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A71398A82BD1277A0050A54E /* Debug */, + A71398A92BD1277A0050A54E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A71398B02BD1277A0050A54E /* Build configuration list for PBXNativeTarget "App macOSUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A71398AC2BD1277A0050A54E /* Debug */, + A71398AD2BD1277A0050A54E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; D23BF5FB27CCCC3300BB4CCD /* Build configuration list for PBXNativeTarget "App tvOS" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -1065,7 +1364,7 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/DataDog/dd-sdk-ios"; requirement = { - branch = GIT_REFERENCE; + branch = "GIT_REFERENCE"; kind = branch; }; }; @@ -1073,7 +1372,7 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/DataDog/dd-sdk-ios"; requirement = { - branch = GIT_REFERENCE; + branch = "GIT_REFERENCE"; kind = branch; }; }; @@ -1090,6 +1389,31 @@ package = 9E73373E26B0123500917C24 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */; productName = DatadogCrashReporting; }; + A71398B52BD12BC60050A54E /* DatadogCore */ = { + isa = XCSwiftPackageProductDependency; + package = 9E73373E26B0123500917C24 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */; + productName = DatadogCore; + }; + A71398B72BD12BC60050A54E /* DatadogCrashReporting */ = { + isa = XCSwiftPackageProductDependency; + package = 9E73373E26B0123500917C24 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */; + productName = DatadogCrashReporting; + }; + A71398B92BD12BC60050A54E /* DatadogLogs */ = { + isa = XCSwiftPackageProductDependency; + package = 9E73373E26B0123500917C24 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */; + productName = DatadogLogs; + }; + A71398BB2BD12BC60050A54E /* DatadogTrace */ = { + isa = XCSwiftPackageProductDependency; + package = 9E73373E26B0123500917C24 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */; + productName = DatadogTrace; + }; + A71398BD2BD12BC60050A54E /* DatadogWebViewTracking */ = { + isa = XCSwiftPackageProductDependency; + package = 9E73373E26B0123500917C24 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */; + productName = DatadogWebViewTracking; + }; D2344E1E29ACDE61007F5BD2 /* DatadogLogs */ = { isa = XCSwiftPackageProductDependency; package = 9E73373E26B0123500917C24 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */; diff --git a/dependency-manager-tests/spm/SPMProject.xcodeproj.src/xcshareddata/xcschemes/App macOS.xcscheme b/dependency-manager-tests/spm/SPMProject.xcodeproj.src/xcshareddata/xcschemes/App macOS.xcscheme new file mode 100644 index 0000000000..46e6000bf4 --- /dev/null +++ b/dependency-manager-tests/spm/SPMProject.xcodeproj.src/xcshareddata/xcschemes/App macOS.xcscheme @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 090d4a808d446e69221589097b664544eb52362c Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Thu, 18 Apr 2024 12:43:23 +0100 Subject: [PATCH 10/16] Remove failing test --- bitrise.yml | 10 ---------- .../spm/SPMProject.xcodeproj.src/project.pbxproj | 8 ++++---- .../xcshareddata/xcschemes/App macOS.xcscheme | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/bitrise.yml b/bitrise.yml index 7566442753..718c34f719 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -392,16 +392,6 @@ workflows: - cache_level: none - project_path: "$BITRISE_SOURCE_DIR/dependency-manager-tests/spm/SPMProject.xcodeproj" - xcpretty_test_options: --color --report html --output "${BITRISE_DEPLOY_DIR}/SPMProject-tvos-tests.html" - - xcode-test: - title: Run SPMProject macOS tests - run_if: '{{enveq "DD_RUN_SMOKE_TESTS" "1"}}' - inputs: - - scheme: App macOS - - destination: platform=macOS,name=macOS - - is_clean_build: 'yes' - - cache_level: none - - project_path: "$BITRISE_SOURCE_DIR/dependency-manager-tests/spm/SPMProject.xcodeproj" - - xcpretty_test_options: --color --report html --output "${BITRISE_DEPLOY_DIR}/SPMProject-macos-tests.html" - script: title: Test Carthage compatibility run_if: '{{enveq "DD_RUN_SMOKE_TESTS" "1"}}' diff --git a/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj b/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj index 2a576280a1..32753a0c7e 100644 --- a/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj +++ b/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj @@ -1038,7 +1038,7 @@ LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MACOSX_DEPLOYMENT_TARGET = 11; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = "com.datadoghq.App-macOS"; + PRODUCT_BUNDLE_IDENTIFIER = com.datadoghq.SPMProjectMacOS; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; @@ -1075,7 +1075,7 @@ LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MACOSX_DEPLOYMENT_TARGET = 11; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = "com.datadoghq.App-macOS"; + PRODUCT_BUNDLE_IDENTIFIER = com.datadoghq.SPMProjectMacOS; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; @@ -1099,7 +1099,7 @@ LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MACOSX_DEPLOYMENT_TARGET = 11; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = "com.datadoghq.App-macOSUITests"; + PRODUCT_BUNDLE_IDENTIFIER = com.datadoghq.SPMProjectMacOSUITests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; @@ -1125,7 +1125,7 @@ LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MACOSX_DEPLOYMENT_TARGET = 11; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = "com.datadoghq.App-macOSUITests"; + PRODUCT_BUNDLE_IDENTIFIER = com.datadoghq.SPMProjectMacOSUITests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; diff --git a/dependency-manager-tests/spm/SPMProject.xcodeproj.src/xcshareddata/xcschemes/App macOS.xcscheme b/dependency-manager-tests/spm/SPMProject.xcodeproj.src/xcshareddata/xcschemes/App macOS.xcscheme index 46e6000bf4..9e772b47d7 100644 --- a/dependency-manager-tests/spm/SPMProject.xcodeproj.src/xcshareddata/xcschemes/App macOS.xcscheme +++ b/dependency-manager-tests/spm/SPMProject.xcodeproj.src/xcshareddata/xcschemes/App macOS.xcscheme @@ -35,7 +35,7 @@ parallelizable = "YES"> From 6ae18fdb0245e8ddf3f941fdc72399ada42d3aaf Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Fri, 19 Apr 2024 11:17:58 +0100 Subject: [PATCH 11/16] PR fixes --- CHANGELOG.md | 2 ++ .../Sources/Core/Context/LowPowerModePublisher.swift | 9 +-------- .../Core/Context/NetworkConnectionInfoPublisher.swift | 8 ++++---- DatadogCore/Sources/Core/DatadogCore.swift | 2 +- DatadogCore/Sources/Core/Storage/Files/File.swift | 2 +- DatadogInternal/Sources/Context/DeviceInfo.swift | 2 +- DatadogInternal/Sources/DD.swift | 4 ++-- .../URLSession/URLSessionTask+Tracking.swift | 2 +- .../URLSession/URLSessionTaskInterception.swift | 2 +- .../Sources/Upload/DefaultJSONEncoder.swift | 2 +- .../Sources/RUMVitals/VitalRefreshRateReader.swift | 2 +- Package.swift | 2 +- .../spm/App macOS/App_macOSApp.swift | 4 ++++ .../spm/App macOS/ContentView.swift | 4 ---- .../spm/SPMProject.xcodeproj.src/project.pbxproj | 10 +++++++++- .../spm/{App => Shared}/DatadogSetup.swift | 0 16 files changed, 30 insertions(+), 27 deletions(-) rename dependency-manager-tests/spm/{App => Shared}/DatadogSetup.swift (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ee935e739..3816ba4368 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [FEATURE] Add support for 128 bit trace IDs. See [#1721][] - [FEATURE] Fatal App Hangs are tracked in RUM. See [#1763][] - [FIX] Avoid name collision with Required Reason APIs. See [#1774][] +- [IMPROVEMENT] Make the SDK compile on macOS 12+. See [#1711][] # 2.9.0 / 11-04-2024 @@ -627,6 +628,7 @@ Release `2.0` introduces breaking changes. Follow the [Migration Guide](MIGRATIO [#1696]: https://github.com/DataDog/dd-sdk-ios/pull/1696 [#1697]: https://github.com/DataDog/dd-sdk-ios/pull/1697 [#1707]: https://github.com/DataDog/dd-sdk-ios/pull/1707 +[#1711]: https://github.com/DataDog/dd-sdk-ios/pull/1711 [#1722]: https://github.com/DataDog/dd-sdk-ios/pull/1722 [#1724]: https://github.com/DataDog/dd-sdk-ios/pull/1724 [#1741]: https://github.com/DataDog/dd-sdk-ios/pull/1741 diff --git a/DatadogCore/Sources/Core/Context/LowPowerModePublisher.swift b/DatadogCore/Sources/Core/Context/LowPowerModePublisher.swift index cab1a9fcfb..11168138a3 100644 --- a/DatadogCore/Sources/Core/Context/LowPowerModePublisher.swift +++ b/DatadogCore/Sources/Core/Context/LowPowerModePublisher.swift @@ -25,18 +25,11 @@ internal final class LowPowerModePublisher: ContextValuePublisher { processInfo: ProcessInfo = .processInfo, notificationCenter: NotificationCenter = .default ) { - if #available(macOS 12.0, *) { - self.initialValue = processInfo.isLowPowerModeEnabled - } else { - self.initialValue = false - } + self.initialValue = processInfo.isLowPowerModeEnabled self.notificationCenter = notificationCenter } func publish(to receiver: @escaping ContextValueReceiver) { - guard #available(macOS 12.0, *) else { - return - } self.observer = notificationCenter .addObserver( forName: .NSProcessInfoPowerStateDidChange, diff --git a/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift b/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift index 4b7b61414b..65b0bb64f1 100644 --- a/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift +++ b/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift @@ -20,7 +20,7 @@ import Network /// We found the pulling model to not be thread-safe: accessing `currentPath` properties lead to occasional crashes. /// The `ThreadSafeNWPathMonitor` listens to path updates and synchonizes the values on `.current` property. /// This adds the necessary thread-safety and keeps the convenience of pulling. -@available(iOS 12, tvOS 12, macOS 10.15, *) +@available(iOS 12, tvOS 12, *) internal struct NWPathMonitorPublisher: ContextValuePublisher { private static let defaultQueue = DispatchQueue( label: "com.datadoghq.nw-path-monitor-publisher", @@ -56,7 +56,7 @@ internal struct NWPathMonitorPublisher: ContextValuePublisher { } extension NetworkConnectionInfo { - @available(iOS 12, tvOS 12, macOS 10.15, *) + @available(iOS 12, tvOS 12, *) init(_ path: NWPath) { self.init( reachability: NetworkConnectionInfo.Reachability(path.status), @@ -75,7 +75,7 @@ extension NetworkConnectionInfo { } extension NetworkConnectionInfo.Reachability { - @available(iOS 12, tvOS 12, macOS 10.14, *) + @available(iOS 12, tvOS 12, *) init(_ status: NWPath.Status) { switch status { case .satisfied: self = .yes @@ -87,7 +87,7 @@ extension NetworkConnectionInfo.Reachability { } extension NetworkConnectionInfo.Interface { - @available(iOS 12, tvOS 12, macOS 10.14, *) + @available(iOS 12, tvOS 12, *) init(_ interface: NWInterface.InterfaceType) { switch interface { case .wifi: self = .wifi diff --git a/DatadogCore/Sources/Core/DatadogCore.swift b/DatadogCore/Sources/Core/DatadogCore.swift index 42a11087ff..7e4e98dfe3 100644 --- a/DatadogCore/Sources/Core/DatadogCore.swift +++ b/DatadogCore/Sources/Core/DatadogCore.swift @@ -422,7 +422,7 @@ extension DatadogContextProvider { subscribe(\.launchTime, to: LaunchTimePublisher()) #endif - if #available(iOS 12, tvOS 12, macOS 10.15, *) { + if #available(iOS 12, tvOS 12, *) { subscribe(\.networkConnectionInfo, to: NWPathMonitorPublisher()) } else { assign(reader: SCNetworkReachabilityReader(), to: \.networkConnectionInfo) diff --git a/DatadogCore/Sources/Core/Storage/Files/File.swift b/DatadogCore/Sources/Core/Storage/Files/File.swift index c6eca10d00..0dce3b8f2a 100644 --- a/DatadogCore/Sources/Core/Storage/Files/File.swift +++ b/DatadogCore/Sources/Core/Storage/Files/File.swift @@ -70,7 +70,7 @@ internal struct File: WritableFile, ReadableFile { ``` This is fixed in iOS 14/Xcode 12 */ - if #available(iOS 13.4, tvOS 13.4, macOS 10.15.4, *) { + if #available(iOS 13.4, tvOS 13.4, *) { defer { try? fileHandle.close() } try fileHandle.seekToEnd() try fileHandle.write(contentsOf: data) diff --git a/DatadogInternal/Sources/Context/DeviceInfo.swift b/DatadogInternal/Sources/Context/DeviceInfo.swift index ceec8d4328..12c2baffb1 100644 --- a/DatadogInternal/Sources/Context/DeviceInfo.swift +++ b/DatadogInternal/Sources/Context/DeviceInfo.swift @@ -96,7 +96,7 @@ extension DeviceInfo { #endif } } -#else +#elseif os(macOS) /// Creates device info based on Host description. /// /// - Parameters: diff --git a/DatadogInternal/Sources/DD.swift b/DatadogInternal/Sources/DD.swift index 3e68e1b1d4..fd10e21633 100644 --- a/DatadogInternal/Sources/DD.swift +++ b/DatadogInternal/Sources/DD.swift @@ -32,7 +32,7 @@ import OSLog /// Function printing `String` content to console. public var consolePrint: (String, CoreLoggerLevel) -> Void = { message, level in #if canImport(OSLog) - if #available(iOS 14.0, tvOS 14.0, macOS 11.0, *) { + if #available(iOS 14.0, tvOS 14.0, *) { switch level { case .debug: Logger.datadog.debug("\(message, privacy: .private)") case .warn: Logger.datadog.warning("\(message, privacy: .private)") @@ -48,7 +48,7 @@ public var consolePrint: (String, CoreLoggerLevel) -> Void = { message, level in } #if canImport(OSLog) -@available(iOS 14.0, tvOS 14.0, macOS 11.0, *) +@available(iOS 14.0, tvOS 14.0, *) extension Logger { static let datadog = Logger(subsystem: "dd-sdk-ios", category: "DatadogInternal") } diff --git a/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTask+Tracking.swift b/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTask+Tracking.swift index c97085867d..da1a44f42c 100644 --- a/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTask+Tracking.swift +++ b/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTask+Tracking.swift @@ -21,7 +21,7 @@ extension DatadogExtension where ExtendedType: URLSessionTask { /// Returns the delegate instance the task is reporting to. var delegate: URLSessionDelegate? { - if #available(iOS 15.0, tvOS 15.0, macOS 12.0, *), let delegate = type.delegate { + if #available(iOS 15.0, tvOS 15.0, *), let delegate = type.delegate { return delegate } diff --git a/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTaskInterception.swift b/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTaskInterception.swift index 62592acd36..609bfc1996 100644 --- a/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTaskInterception.swift +++ b/DatadogInternal/Sources/NetworkInstrumentation/URLSession/URLSessionTaskInterception.swift @@ -255,7 +255,7 @@ extension ResourceMetrics { download = DateInterval(start: downloadStart, end: downloadEnd) } - if #available(iOS 13.0, tvOS 13, macOS 10.15, *) { + if #available(iOS 13.0, tvOS 13, *) { responseSize = mainTransaction.countOfResponseBodyBytesAfterDecoding } } diff --git a/DatadogInternal/Sources/Upload/DefaultJSONEncoder.swift b/DatadogInternal/Sources/Upload/DefaultJSONEncoder.swift index 69a7f96138..e6fc899d85 100644 --- a/DatadogInternal/Sources/Upload/DefaultJSONEncoder.swift +++ b/DatadogInternal/Sources/Upload/DefaultJSONEncoder.swift @@ -16,7 +16,7 @@ extension DatadogExtension where ExtendedType == JSONEncoder { let formatted = iso8601DateFormatter.string(from: date) try container.encode(formatted) } - if #available(iOS 13, tvOS 13, macOS 10.15, *) { + if #available(iOS 13, tvOS 13, *) { encoder.outputFormatting = [.withoutEscapingSlashes] } return encoder diff --git a/DatadogRUM/Sources/RUMVitals/VitalRefreshRateReader.swift b/DatadogRUM/Sources/RUMVitals/VitalRefreshRateReader.swift index e69b3c9380..021a3a1133 100644 --- a/DatadogRUM/Sources/RUMVitals/VitalRefreshRateReader.swift +++ b/DatadogRUM/Sources/RUMVitals/VitalRefreshRateReader.swift @@ -173,7 +173,7 @@ extension CADisplayLink: FrameInfoProvider { var maximumDeviceFramesPerSecond: Int { #if swift(>=5.9) && os(visionOS) // Hardcoded as for now there's no good way of extracting maximum FPS on VisionOS - // https://developer.apple.com/documentation/visionos/analyzing-the-performance-of-your-visionos-app/ + // https://developer.apple.com/documentation/visionos/analyzing-the-performance-of-your-visionos-app#Inspect-frame-rendering-performance 90 #else UIScreen.main.maximumFramesPerSecond diff --git a/Package.swift b/Package.swift index 142869f629..87c819d351 100644 --- a/Package.swift +++ b/Package.swift @@ -8,7 +8,7 @@ let package = Package( platforms: [ .iOS(.v11), .tvOS(.v11), - .macOS(.v10_15) + .macOS(.v12) ], products: [ .library( diff --git a/dependency-manager-tests/spm/App macOS/App_macOSApp.swift b/dependency-manager-tests/spm/App macOS/App_macOSApp.swift index 1053dd8d9c..123623e06c 100644 --- a/dependency-manager-tests/spm/App macOS/App_macOSApp.swift +++ b/dependency-manager-tests/spm/App macOS/App_macOSApp.swift @@ -13,4 +13,8 @@ struct App_macOSApp: App { ContentView() } } + + init() { + DatadogSetup.initialize() + } } diff --git a/dependency-manager-tests/spm/App macOS/ContentView.swift b/dependency-manager-tests/spm/App macOS/ContentView.swift index 97bdbda50b..1fc7b91149 100644 --- a/dependency-manager-tests/spm/App macOS/ContentView.swift +++ b/dependency-manager-tests/spm/App macOS/ContentView.swift @@ -15,8 +15,4 @@ struct ContentView: View { } .padding() } - - init() { - DatadogSetup.initialize() - } } diff --git a/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj b/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj index 32753a0c7e..c678bf0b60 100644 --- a/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj +++ b/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj @@ -217,6 +217,7 @@ isa = PBXGroup; children = ( 61CE5FD42461D3C2005EA621 /* xcconfigs */, + A787CA7D2BD277190053CEBE /* Shared */, 61C363D824374D5F00C4D4E6 /* App */, 61C363EF24374D6100C4D4E6 /* AppTests */, 61C363FA24374D6100C4D4E6 /* AppUITests */, @@ -250,7 +251,6 @@ 61C363DD24374D5F00C4D4E6 /* ViewController.swift */, 61C363E724374D6000C4D4E6 /* Info.plist */, D22919302B76589B00C38A18 /* PrivacyInfo.xcprivacy */, - A71398B12BD12B6D0050A54E /* DatadogSetup.swift */, ); path = App; sourceTree = ""; @@ -308,6 +308,14 @@ path = "App macOSUITests"; sourceTree = ""; }; + A787CA7D2BD277190053CEBE /* Shared */ = { + isa = PBXGroup; + children = ( + A71398B12BD12B6D0050A54E /* DatadogSetup.swift */, + ); + path = Shared; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ diff --git a/dependency-manager-tests/spm/App/DatadogSetup.swift b/dependency-manager-tests/spm/Shared/DatadogSetup.swift similarity index 100% rename from dependency-manager-tests/spm/App/DatadogSetup.swift rename to dependency-manager-tests/spm/Shared/DatadogSetup.swift From ec760861317cd4f4676ce1e94788fc6f5a4f3b28 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Fri, 19 Apr 2024 11:26:58 +0100 Subject: [PATCH 12/16] Documentation update --- DatadogInternal/Sources/Context/DeviceInfo.swift | 1 - SUPPORTED-VERSIONS.md | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/DatadogInternal/Sources/Context/DeviceInfo.swift b/DatadogInternal/Sources/Context/DeviceInfo.swift index 12c2baffb1..99b2f885b5 100644 --- a/DatadogInternal/Sources/Context/DeviceInfo.swift +++ b/DatadogInternal/Sources/Context/DeviceInfo.swift @@ -101,7 +101,6 @@ extension DeviceInfo { /// /// - Parameters: /// - processInfo: The current process information. -/// - device: The `Host` description. extension DeviceInfo { public init( processInfo: ProcessInfo = .processInfo diff --git a/SUPPORTED-VERSIONS.md b/SUPPORTED-VERSIONS.md index e259c2584a..6f0fa258d0 100644 --- a/SUPPORTED-VERSIONS.md +++ b/SUPPORTED-VERSIONS.md @@ -6,17 +6,17 @@ | **tvOS** | ✅ | `11+` | | **iPadOS** | ✅ | `11+` | | **visionOS** | ⚠️ | `1.0+` | -| **macOS** | ⚠️ | `10.15+` | +| **macOS** | ⚠️ | `12+` | | **watchOS**| ❌ | `n/a` | | **Linux** | ❌ | `n/a` | ## VisionOS -VisionOS is not officially supported by Datadog SDK. Some features may not be fully functional. Note that `CrashReporting` is not supported on VisionOS, due to lack of support on the [PLCrashReporter side](https://github.com/microsoft/plcrashreporter/issues/288). +VisionOS is not officially supported by Datadog SDK. Some features may not be fully functional. Note that `DatadogCrashReporting` is not supported on VisionOS, due to lack of support on the [PLCrashReporter side](https://github.com/microsoft/plcrashreporter/issues/288). ## MacOS -MacOS is not officially supported by Datadog SDK. Some features may not be fully functional. Note that `RUM`, which heavily depends on `UIKit` does not build on macOS. +MacOS is not officially supported by Datadog SDK. Some features may not be fully functional. Note that `DatadogRUM`, `DatadogSessionReplay` and `DatadogObjc` which heavily depend on `UIKit` do not build on macOS. ## Xcode From afa261c0f120e9389a93102b3b5364b6d160ae83 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Fri, 19 Apr 2024 14:51:08 +0100 Subject: [PATCH 13/16] Fix deployment target on SPM project --- .../spm/SPMProject.xcodeproj.src/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj b/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj index c678bf0b60..ecf6a4b36c 100644 --- a/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj +++ b/dependency-manager-tests/spm/SPMProject.xcodeproj.src/project.pbxproj @@ -1044,7 +1044,7 @@ "@executable_path/../Frameworks", ); LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 11; + MACOSX_DEPLOYMENT_TARGET = 12; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.datadoghq.SPMProjectMacOS; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1081,7 +1081,7 @@ "@executable_path/../Frameworks", ); LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 11; + MACOSX_DEPLOYMENT_TARGET = 12; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.datadoghq.SPMProjectMacOS; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1105,7 +1105,7 @@ GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 11; + MACOSX_DEPLOYMENT_TARGET = 12; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.datadoghq.SPMProjectMacOSUITests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1131,7 +1131,7 @@ GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 11; + MACOSX_DEPLOYMENT_TARGET = 12; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.datadoghq.SPMProjectMacOSUITests; PRODUCT_NAME = "$(TARGET_NAME)"; From 7b094e829a58ffba2d11fbce42a5ff0f10d149c2 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Mon, 22 Apr 2024 09:58:55 +0100 Subject: [PATCH 14/16] PR fixes --- .../Core/Context/NetworkConnectionInfoPublisher.swift | 2 +- SUPPORTED-VERSIONS.md | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift b/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift index 65b0bb64f1..f0c8069cbb 100644 --- a/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift +++ b/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift @@ -158,7 +158,7 @@ extension NetworkConnectionInfo.Interface { } self = .cellular #else - self = .other + self = nil #endif } } diff --git a/SUPPORTED-VERSIONS.md b/SUPPORTED-VERSIONS.md index 6f0fa258d0..6f56125caa 100644 --- a/SUPPORTED-VERSIONS.md +++ b/SUPPORTED-VERSIONS.md @@ -5,8 +5,10 @@ | **iOS** | ✅ | `11+` | | **tvOS** | ✅ | `11+` | | **iPadOS** | ✅ | `11+` | -| **visionOS** | ⚠️ | `1.0+` | +| **macOS (Designed for iPad)** | ✅ | `11+` | +| **macOS (Catalyst)** | ⚠️ | `12+` | | **macOS** | ⚠️ | `12+` | +| **visionOS** | ⚠️ | `1.0+` | | **watchOS**| ❌ | `n/a` | | **Linux** | ❌ | `n/a` | @@ -18,6 +20,10 @@ VisionOS is not officially supported by Datadog SDK. Some features may not be fu MacOS is not officially supported by Datadog SDK. Some features may not be fully functional. Note that `DatadogRUM`, `DatadogSessionReplay` and `DatadogObjc` which heavily depend on `UIKit` do not build on macOS. +## Catalyst + +We support Catalyst in build mode only, which means that macOS target will build, but functionalities for the SDK might not work for this target. + ## Xcode SDK is built using the most recent version of Xcode, but we make sure that it's backward compatible with the [lowest supported Xcode version for AppStore submission](https://developer.apple.com/news/?id=jd9wcyov). @@ -52,9 +58,6 @@ We currently support integration of the SDK using following dependency managers. *Note: Third party networking libraries can be instrumented by implementing custom `DDURLSessionDelegate`.* -## Catalyst -We support Catalyst in build mode only, which means that macOS target will build, but functionalities for the SDK won't work for this target. - ## Dependencies The Datadog SDK depends on the following third-party library: - [PLCrashReporter](https://github.com/microsoft/plcrashreporter) 1.11.1 From 39d57552db94a181cb5718724f63a359bea1e779 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Mon, 22 Apr 2024 22:09:15 +0100 Subject: [PATCH 15/16] Revert nil interface --- .../Sources/Core/Context/NetworkConnectionInfoPublisher.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift b/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift index f0c8069cbb..65b0bb64f1 100644 --- a/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift +++ b/DatadogCore/Sources/Core/Context/NetworkConnectionInfoPublisher.swift @@ -158,7 +158,7 @@ extension NetworkConnectionInfo.Interface { } self = .cellular #else - self = nil + self = .other #endif } } From c08e66b001e10bf523725d5d80fa5808a476b5c1 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Tue, 23 Apr 2024 19:17:08 +0100 Subject: [PATCH 16/16] Update dependency-manager-tests/spm/Shared/DatadogSetup.swift Co-authored-by: Ganesh Jangir --- dependency-manager-tests/spm/Shared/DatadogSetup.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dependency-manager-tests/spm/Shared/DatadogSetup.swift b/dependency-manager-tests/spm/Shared/DatadogSetup.swift index 899fc5fc98..43172f15e2 100644 --- a/dependency-manager-tests/spm/Shared/DatadogSetup.swift +++ b/dependency-manager-tests/spm/Shared/DatadogSetup.swift @@ -32,6 +32,7 @@ enum DatadogSetup { Trace.enable() logger?.info("It works") - _ = Tracer.shared().startSpan(operationName: "this too") + let span = Tracer.shared().startSpan(operationName: "this too") + span.finish() } }