Skip to content

Commit

Permalink
Crash Reporter re-enabled for SPM
Browse files Browse the repository at this point in the history
  • Loading branch information
buranmert committed Jul 27, 2021
1 parent c6215de commit e475f16
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 70 deletions.
1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
github "lyft/Kronos" ~> 4.2
github "microsoft/plcrashreporter" == 1.8.1
1 change: 0 additions & 1 deletion Cartfile.private

This file was deleted.

4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ export DD_SDK_TESTING_XCCONFIG_CI
define DD_SDK_BASE_XCCONFIG
// Active compilation conditions - only enabled on local machine:\n
// - DD_SDK_ENABLE_INTERNAL_MONITORING - enables Internal Monitoring APIs\n
// - DD_SDK_ENABLE_EXPERIMENTAL_APIS - enables APIs which are not available in released version of the SDK\n
// - DD_SDK_COMPILED_FOR_TESTING - conditions the SDK code compiled for testing\n
SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) DD_SDK_ENABLE_INTERNAL_MONITORING DD_SDK_ENABLE_EXPERIMENTAL_APIS DD_SDK_COMPILED_FOR_TESTING\n
SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) DD_SDK_ENABLE_INTERNAL_MONITORING DD_SDK_COMPILED_FOR_TESTING\n
\n
// To build only active architecture for all configurations.\n
// TODO: RUMM-1200 We can perhaps remove this fix when carthage supports pre-build xcframeworks.\n
Expand All @@ -43,7 +42,6 @@ export DD_SDK_DATADOG_XCCONFIG
# Installs tools and dependencies with homebrew.
# Do not call 'brew update' and instead let Bitrise use its own brew bottle mirror.
dependencies:
@./tools/crash-reporting-patch/enable-crash-reporting.sh
@echo "⚙️ Installing dependencies..."
@brew list swiftlint &>/dev/null || brew install swiftlint
@brew upgrade carthage
Expand Down
13 changes: 13 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ let package = Package(
type: .static,
targets: ["DatadogObjc"]
),
.library(
name: "DatadogCrashReporting",
type: .static,
targets: ["DatadogCrashReporting"]
),
],
dependencies: [
.package(name: "Kronos", url: "https://github.com/lyft/Kronos.git", from: "4.2.1"),
.package(name: "PLCrashReporter", url: "https://github.com/microsoft/plcrashreporter.git", from: "1.8.1"),
],
targets: [
.target(
Expand All @@ -50,5 +56,12 @@ let package = Package(
.target(
name: "_Datadog_Private"
),
.target(
name: "DatadogCrashReporting",
dependencies: [
"Datadog",
.product(name: "CrashReporter", package: "PLCrashReporter"),
]
)
]
)
40 changes: 2 additions & 38 deletions Sources/Datadog/CrashReporting/DDCrashReportingPluginType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import Foundation

#if DD_SDK_ENABLE_EXPERIMENTAL_APIS
/// Crash Report format supported by Datadog SDK.
@objc
public class DDCrashReport: NSObject {
Expand All @@ -21,12 +20,12 @@ public class DDCrashReport: NSObject {
/// The last context injected through `inject(context:)`
internal let context: Data?

#if DD_SDK_ENABLE_INTERNAL_MONITORING
#if DD_SDK_ENABLE_INTERNAL_MONITORING
/// Additional diagnostic information about the crash report, collected for `DatadogCrashReporting` observability.
/// Available only if internal monitoring is enabled, disabled by default.
/// See: `Datadog.Configuration.Builder.enableInternalMonitoring(clientToken:)`.
public var diagnosticInfo: [String: Encodable] = [:]
#endif
#endif

public init(
date: Date?,
Expand Down Expand Up @@ -65,38 +64,3 @@ public protocol DDCrashReportingPluginType: AnyObject {
/// It is called on a background thread and succeeding calls are synchronized.
func inject(context: Data)
}

#else

@objc
internal class DDCrashReport: NSObject {
internal let date: Date?
internal let type: String
internal let message: String
internal let stackTrace: String
internal let context: Data?
#if DD_SDK_ENABLE_INTERNAL_MONITORING
internal var diagnosticInfo: [String: Encodable] = [:]
#endif
internal init(
date: Date?,
type: String,
message: String,
stackTrace: String,
context: Data?
) {
self.date = date
self.type = type
self.message = message
self.stackTrace = stackTrace
self.context = context
}
}

@objc
internal protocol DDCrashReportingPluginType: class {
func readPendingCrashReport(completion: (DDCrashReport?) -> Bool)
func inject(context: Data)
}

#endif
2 changes: 0 additions & 2 deletions Sources/Datadog/DatadogConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ extension Datadog {
return self
}

#if DD_SDK_ENABLE_EXPERIMENTAL_APIS
// MARK: - Crash Reporting Configuration

/// Enables the crash reporting feature.
Expand All @@ -630,7 +629,6 @@ extension Datadog {
configuration.crashReportingPlugin = crashReportingPlugin
return self
}
#endif

#if DD_SDK_ENABLE_INTERNAL_MONITORING
// MARK: - Internal Monitoring Configuration
Expand Down
2 changes: 0 additions & 2 deletions Sources/DatadogObjc/DatadogConfiguration+objc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,10 @@ public class DDConfigurationBuilder: NSObject {
_ = sdkBuilder.enableRUM(enabled)
}

#if DD_SDK_ENABLE_EXPERIMENTAL_APIS
@objc
public func enableCrashReporting(using crashReportingPlugin: DDCrashReportingPluginType) {
_ = sdkBuilder.enableCrashReporting(using: crashReportingPlugin)
}
#endif

@objc
public func set(endpoint: DDEndpoint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
9E9D5E8B25F90FC6002F12A0 /* DatadogObjc.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9E9D5E8625F90FC6002F12A0 /* DatadogObjc.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9E9D5E8C25F90FC6002F12A0 /* Datadog.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E9D5E8725F90FC6002F12A0 /* Datadog.xcframework */; };
9E9D5E8D25F90FC6002F12A0 /* Datadog.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9E9D5E8725F90FC6002F12A0 /* Datadog.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9EF87B8C26B04E1F00998076 /* CrashReporter.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 615D9E652604B5AB006DC6D1 /* CrashReporter.xcframework */; };
9EF87B8D26B04E1F00998076 /* CrashReporter.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 615D9E652604B5AB006DC6D1 /* CrashReporter.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9EF87B8E26B04E1F00998076 /* DatadogCrashReporting.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 615D9E6A2604B5B1006DC6D1 /* DatadogCrashReporting.xcframework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -46,6 +49,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
9EF87B8D26B04E1F00998076 /* CrashReporter.xcframework in Embed Frameworks */,
9E9D5E8D25F90FC6002F12A0 /* Datadog.xcframework in Embed Frameworks */,
9E9D5E8B25F90FC6002F12A0 /* DatadogObjc.xcframework in Embed Frameworks */,
9E9D5E8925F90FC6002F12A0 /* Kronos.xcframework in Embed Frameworks */,
Expand Down Expand Up @@ -83,9 +87,11 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9EF87B8C26B04E1F00998076 /* CrashReporter.xcframework in Frameworks */,
9E9D5E8C25F90FC6002F12A0 /* Datadog.xcframework in Frameworks */,
9E9D5E8A25F90FC6002F12A0 /* DatadogObjc.xcframework in Frameworks */,
9E9D5E8825F90FC6002F12A0 /* Kronos.xcframework in Frameworks */,
9EF87B8E26B04E1F00998076 /* DatadogCrashReporting.xcframework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import UIKit
import Datadog
import DatadogObjc
import DatadogCrashReporting

internal class ViewController: UIViewController {
private var logger: Logger! // swiftlint:disable:this implicitly_unwrapped_optional
Expand All @@ -19,6 +20,7 @@ internal class ViewController: UIViewController {
trackingConsent: .granted,
configuration: Datadog.Configuration
.builderUsing(clientToken: "abc", environment: "tests")
.enableCrashReporting(using: DDCrashReportingPlugin())
.build()
)

Expand Down
4 changes: 2 additions & 2 deletions dependency-manager-tests/carthage/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test:
@echo "🧪 Check if expected frameworks exist in $(PWD)/Carthage/Build/"
@[ -e "Carthage/Build/Datadog.xcframework" ] && echo "Datadog.xcframework - OK" || { echo "Datadog.xcframework - missing"; false; }
@[ -e "Carthage/Build/DatadogObjc.xcframework" ] && echo "DatadogObjc.xcframework - OK" || { echo "DatadogObjc.xcframework - missing"; false; }
@[ ! -e "Carthage/Build/DatadogCrashReporting.xcframework" ] && echo "DatadogCrashReporting.xcframework - is not there 👍" || { echo "DatadogCrashReporting.xcframework - should not be there"; false; }
@[ -e "Carthage/Build/DatadogCrashReporting.xcframework" ] && echo "DatadogCrashReporting.xcframework - OK" || { echo "DatadogCrashReporting.xcframework - missing"; false; }
@[ -e "Carthage/Build/Kronos.xcframework" ] && echo "Kronos.xcframework - OK" || { echo "Kronos.xcframework - missing"; false; }
@[ ! -e "Carthage/Build/CrashReporter.xcframework" ] && echo "CrashReporter.xcframework - is not there 👍" || { echo "CrashReporter.xcframework - should not be there"; false; }
@[ -e "Carthage/Build/CrashReporter.xcframework" ] && echo "CrashReporter.xcframework - OK" || { echo "CrashReporter.xcframework - missing"; false; }
@echo "🧪 SUCCEEDED"
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
61C363E624374D6000C4D4E6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 61C363E424374D6000C4D4E6 /* LaunchScreen.storyboard */; };
61C363F124374D6100C4D4E6 /* SPMProjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61C363F024374D6100C4D4E6 /* SPMProjectTests.swift */; };
61C363FC24374D6100C4D4E6 /* SPMProjectUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61C363FB24374D6100C4D4E6 /* SPMProjectUITests.swift */; };
61DA9CB6260BA1FA00366408 /* DatadogStatic in Frameworks */ = {isa = PBXBuildFile; productRef = 61DA9CB5260BA1FA00366408 /* DatadogStatic */; };
9E73374026B0123500917C24 /* DatadogCrashReporting in Frameworks */ = {isa = PBXBuildFile; productRef = 9E73373F26B0123500917C24 /* DatadogCrashReporting */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -70,7 +70,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
61DA9CB6260BA1FA00366408 /* DatadogStatic in Frameworks */,
9E73374026B0123500917C24 /* DatadogCrashReporting in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -180,7 +180,7 @@
);
name = SPMProject;
packageProductDependencies = (
61DA9CB5260BA1FA00366408 /* DatadogStatic */,
9E73373F26B0123500917C24 /* DatadogCrashReporting */,
);
productName = SPMProject;
productReference = 61C363D624374D5F00C4D4E6 /* SPMProject.app */;
Expand Down Expand Up @@ -255,7 +255,7 @@
);
mainGroup = 61C363CD24374D5F00C4D4E6;
packageReferences = (
61C3640924374DF200C4D4E6 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */,
9E73373E26B0123500917C24 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */,
);
productRefGroup = 61C363D724374D5F00C4D4E6 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -676,9 +676,9 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
61C3640924374DF200C4D4E6 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */ = {
9E73373E26B0123500917C24 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/DataDog/dd-sdk-ios";
repositoryURL = "https://github.com/DataDog/dd-sdk-ios/";
requirement = {
branch = REMOTE_GIT_REFERENCE;
kind = branch;
Expand All @@ -687,10 +687,10 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
61DA9CB5260BA1FA00366408 /* DatadogStatic */ = {
9E73373F26B0123500917C24 /* DatadogCrashReporting */ = {
isa = XCSwiftPackageProductDependency;
package = 61C3640924374DF200C4D4E6 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */;
productName = DatadogStatic;
package = 9E73373E26B0123500917C24 /* XCRemoteSwiftPackageReference "dd-sdk-ios" */;
productName = DatadogCrashReporting;
};
/* End XCSwiftPackageProductDependency section */
};
Expand Down
2 changes: 2 additions & 0 deletions dependency-manager-tests/spm/SPMProject/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import UIKit
import Datadog
import DatadogCrashReporting

internal class ViewController: UIViewController {
private var logger: Logger! // swiftlint:disable:this implicitly_unwrapped_optional
Expand All @@ -18,6 +19,7 @@ internal class ViewController: UIViewController {
trackingConsent: .granted,
configuration: Datadog.Configuration
.builderUsing(clientToken: "abc", environment: "tests")
.enableCrashReporting(using: DDCrashReportingPlugin())
.build()
)

Expand Down
13 changes: 0 additions & 13 deletions tools/crash-reporting-patch/enable-crash-reporting.sh

This file was deleted.

0 comments on commit e475f16

Please sign in to comment.