Skip to content

Commit

Permalink
Merge pull request #55 from DataDog/buranmert/RUMM-323-drop-macOS
Browse files Browse the repository at this point in the history
RUMM-323 `macOS/Catalyst` support dropped
  • Loading branch information
buranmert authored Mar 26, 2020
2 parents 72c0909 + 01bb111 commit 6df8427
Show file tree
Hide file tree
Showing 38 changed files with 1,527 additions and 89 deletions.
3 changes: 1 addition & 2 deletions Datadog.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "Datadog"
s.version = "1.0.0-beta2"
s.summary = "Datadog Swift SDK for iOS and macOS."
s.summary = "Datadog Swift SDK for iOS."

s.homepage = "https://www.datadoghq.com"
s.social_media_url = "https://twitter.com/datadoghq"
Expand All @@ -11,7 +11,6 @@ Pod::Spec.new do |s|

s.swift_version = '5.1'
s.ios.deployment_target = '11.0'
s.osx.deployment_target = '10.14'

s.source = { :git => 'https://github.com/DataDog/dd-sdk-ios.git', :tag => s.version.to_s }

Expand Down
10 changes: 6 additions & 4 deletions Datadog/Datadog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,6 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = YES;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = NO;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -1042,7 +1041,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.datadogqh.Datadog;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MACCATALYST = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -1053,7 +1052,6 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = YES;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = NO;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -1067,7 +1065,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.datadogqh.Datadog;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MACCATALYST = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -1089,6 +1087,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SUPPORTS_MACCATALYST = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -1110,6 +1109,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SUPPORTS_MACCATALYST = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -1133,6 +1133,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.datadogqh.DatadogObjc;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -1156,6 +1157,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.datadogqh.DatadogObjc;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down
3 changes: 1 addition & 2 deletions DatadogObjc.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "DatadogObjc"
s.version = "1.0.0-beta2"
s.summary = "Datadog Objective-C SDK for iOS and macOS."
s.summary = "Datadog Objective-C SDK for iOS."

s.homepage = "https://www.datadoghq.com"
s.social_media_url = "https://twitter.com/datadoghq"
Expand All @@ -11,7 +11,6 @@ Pod::Spec.new do |s|

s.swift_version = '5.1'
s.ios.deployment_target = '11.0'
s.osx.deployment_target = '10.14'

s.source = { :git => 'https://github.com/DataDog/dd-sdk-ios.git', :tag => s.version.to_s }

Expand Down
3 changes: 1 addition & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import PackageDescription
let package = Package(
name: "Datadog",
platforms: [
.iOS(.v11),
.macOS(.v10_14),
.iOS(.v11)
],
products: [
.library(
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Datadog SDK for iOS

> Swift library to interact with Datadog. Supports iOS and macOS.
> Swift library to interact with Datadog. Supports iOS only.
⚠️ This is an **alpha version** of the SDK and source breaking changes might be introduced in `1.0.0`.

Expand Down
35 changes: 12 additions & 23 deletions Sources/Datadog/Core/System/MobileDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
* Copyright 2019-2020 Datadog, Inc.
*/

import Foundation
#if canImport(UIKit)
import UIKit
#endif

/// Describes current mobile device.
internal class MobileDevice {
Expand Down Expand Up @@ -55,7 +52,6 @@ internal class MobileDevice {
self.currentBatteryStatus = currentBatteryStatus
}

#if canImport(UIKit)
convenience init(uiDevice: UIDevice, processInfo: ProcessInfo) {
let wasBatteryMonitoringEnabled = uiDevice.isBatteryMonitoringEnabled
self.init(
Expand All @@ -73,32 +69,26 @@ internal class MobileDevice {
}
)
}
#endif

/// Returns current mobile device if `UIDevice` is available on this platform.
/// On other platforms returns `nil`.
static var current: MobileDevice? {
#if canImport(UIKit)
#if !targetEnvironment(simulator)
// Real device
return MobileDevice(uiDevice: UIDevice.current, processInfo: ProcessInfo.processInfo)
#else
// iOS Simulator - battery monitoring doesn't work on Simulator, so return "always OK" value
return MobileDevice(
model: UIDevice.current.model,
osName: UIDevice.current.systemName,
osVersion: UIDevice.current.systemVersion,
enableBatteryStatusMonitoring: {},
resetBatteryStatusMonitoring: {},
currentBatteryStatus: { BatteryStatus(state: .full, level: 1, isLowPowerModeEnabled: false) }
)
#endif
#if !targetEnvironment(simulator)
// Real device
return MobileDevice(uiDevice: UIDevice.current, processInfo: ProcessInfo.processInfo)
#else
return nil
// iOS Simulator - battery monitoring doesn't work on Simulator, so return "always OK" value
return MobileDevice(
model: UIDevice.current.model,
osName: UIDevice.current.systemName,
osVersion: UIDevice.current.systemVersion,
enableBatteryStatusMonitoring: {},
resetBatteryStatusMonitoring: {},
currentBatteryStatus: { BatteryStatus(state: .full, level: 1, isLowPowerModeEnabled: false) }
)
#endif
}

#if canImport(UIKit)
private static func toBatteryState(_ uiDeviceBatteryState: UIDevice.BatteryState) -> BatteryStatus.State {
switch uiDeviceBatteryState {
case .unknown: return .unknown
Expand All @@ -108,5 +98,4 @@ internal class MobileDevice {
@unknown default: return.unknown
}
}
#endif
}
2 changes: 1 addition & 1 deletion Sources/Datadog/Core/System/NetworkPathMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension NWPathMonitor {
let info = currentPath

let isCurrentPathConstrained: Bool? = {
if #available(iOS 13.0, macOS 10.15, *) {
if #available(iOS 13.0, *) {
return info.isConstrained
} else {
return nil
Expand Down
2 changes: 1 addition & 1 deletion Sources/Datadog/Datadog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foundation

/// SDK version associated with logs.
/// Should be synced with SDK releases.
internal let sdkVersion = "1.0.0-beta2"
internal let sdkVersion = "1.0.0-beta3"

/// Datadog SDK configuration object.
public class Datadog {
Expand Down
10 changes: 1 addition & 9 deletions Tests/DatadogTests/Datadog/Core/System/MobileDeviceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
*/

import XCTest
@testable import Datadog
#if canImport(UIKit)
import UIKit
#endif
@testable import Datadog

class MobileDeviceTests: XCTestCase {
#if canImport(UIKit)
func testWhenRunningOnMobile_itReturnsDevice() {
XCTAssertNotNil(MobileDevice.current)
}
Expand Down Expand Up @@ -74,9 +71,4 @@ class MobileDeviceTests: XCTestCase {
mobileDevice.resetBatteryStatusMonitoring()
XCTAssertFalse(uiDevice.isBatteryMonitoringEnabled)
}
#else
func testWhenRunningOnOtherPlatforms_itReturnsNil() {
XCTAssertNil(MobileDevice.current)
}
#endif
}
2 changes: 1 addition & 1 deletion Tests/DatadogTests/Datadog/LoggerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class LoggerTests: XCTestCase {
logMatcher.assertValue(forKeyPath: "network.client.is_expensive", isTypeOf: Bool.self)
logMatcher.assertValue(forKeyPath: "network.client.supports_ipv4", isTypeOf: Bool.self)
logMatcher.assertValue(forKeyPath: "network.client.supports_ipv6", isTypeOf: Bool.self)
if #available(iOS 13.0, macOS 10.15, *) {
if #available(iOS 13.0, *) {
logMatcher.assertValue(forKeyPath: "network.client.is_constrained", isTypeOf: Bool.self)
}
}
Expand Down
2 changes: 0 additions & 2 deletions Tests/DatadogTests/Datadog/Mocks/FoundationMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ extension URLRequest {

// MARK: - Process

#if os(iOS)
class ProcessInfoMock: ProcessInfo {
private var _isLowPowerModeEnabled: Bool

Expand All @@ -301,4 +300,3 @@ class ProcessInfoMock: ProcessInfo {

override var isLowPowerModeEnabled: Bool { _isLowPowerModeEnabled }
}
#endif
3 changes: 0 additions & 3 deletions Tests/DatadogTests/Datadog/Mocks/UIKitMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Copyright 2019-2020 Datadog, Inc.
*/

#if canImport(UIKit)
import UIKit

/*
Expand Down Expand Up @@ -52,5 +51,3 @@ class UIDeviceMock: UIDevice {
override var batteryState: UIDevice.BatteryState { _batteryState }
override var batteryLevel: Float { _batteryLevel }
}

#endif
1 change: 0 additions & 1 deletion dependency-manager-tests/spm/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/

# Ignore `Package.resolved` and `Package.swift` as they will be re-created for every test run.
Expand Down
8 changes: 5 additions & 3 deletions dependency-manager-tests/spm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ endif

test:
@echo "⚙️ Testing SPM for remote branch: '${GIT_BRANCH}'..."
@sed "s|REMOTE_GIT_BRANCH|${GIT_BRANCH}|g" Package.swift.src > Package.swift
swift package update
swift build
@sed -i "" "s|branch = *.;|branch = ${GIT_BRANCH};|g" SPMProject.xcodeproj/project.pbxproj
@xcodebuild -project SPMProject.xcodeproj \
-scheme "SPMProjectUITests" \
-destination 'platform=iOS Simulator,name=iPhone 11' \
test
@echo "OK 👌"
22 changes: 0 additions & 22 deletions dependency-manager-tests/spm/Package.swift.src

This file was deleted.

5 changes: 5 additions & 0 deletions dependency-manager-tests/spm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ After pushing current branch to remote, run:
$ make
```
to check if SPM is able to fetch `Datadog` dependency from current branch and build the project.

## Important Note:

`make` auto-magically changes current branch for `Datadog` dependency.
By default, current branch is `master`; if you open `SPMProject.xcodeproj` and build, you will fetch `Datadog:master`
Loading

0 comments on commit 6df8427

Please sign in to comment.