From f0c3a6110cb90a8e12e5637a7b1d55e115e1e178 Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Thu, 17 Dec 2020 17:08:46 -0800 Subject: [PATCH 01/13] added SPM project for the RollbarPLCrashReporter module --- CHANGELOG.md | 7 +- RollbarPLCrashReporter/.gitignore | 5 ++ RollbarPLCrashReporter/Package.swift | 78 +++++++++++++++++++ RollbarPLCrashReporter/README.md | 3 + .../RollbarPLCrashReporter.swift | 3 + RollbarPLCrashReporter/Tests/LinuxMain.swift | 7 ++ .../RollbarPLCrashReporterTests.swift | 15 ++++ .../XCTestManifests.swift | 9 +++ .../contents.xcworkspacedata | 3 + .../xcshareddata/WorkspaceSettings.xcsettings | 8 ++ .../xcshareddata/swiftpm/Package.resolved | 9 +++ 11 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 RollbarPLCrashReporter/.gitignore create mode 100644 RollbarPLCrashReporter/Package.swift create mode 100644 RollbarPLCrashReporter/README.md create mode 100644 RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashReporter.swift create mode 100644 RollbarPLCrashReporter/Tests/LinuxMain.swift create mode 100644 RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests/RollbarPLCrashReporterTests.swift create mode 100644 RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests/XCTestManifests.swift create mode 100644 RollbarSDK.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/CHANGELOG.md b/CHANGELOG.md index 34da10b5..0435d8eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,10 @@ The change log has moved to this repo's [GitHub Releases Page](https://github.co ## Release Notes **2.0.0** Preliminary Notes -- feat: added RollbarKSCrash +- feat: added RollbarPLCrashReporter module +- feat: added RollbarKSCrash module +- feat: explicit reporting of NSErrors +- feat: defined default scrub fields - refactor: split out RollbarCommon, RollbarNotifier, RollbarDeploys - refactor: added use of lightweight generics - refactor: added use nullability attributes @@ -35,5 +38,3 @@ The change log has moved to this repo's [GitHub Releases Page](https://github.co - refactor: removed all the deprecated API - refactor: replace NSString-like log level parameters in RollbarLogger interface with RollbarLevel enum - refactor: replace sync-all log methods of Rollbar and RolbarLogger with ones dedicated to each type of payload: string-message, NSException, NSError, etc. -- feat: defined default scrub fields -- feat: explicit reporting of NSErrors diff --git a/RollbarPLCrashReporter/.gitignore b/RollbarPLCrashReporter/.gitignore new file mode 100644 index 00000000..95c43209 --- /dev/null +++ b/RollbarPLCrashReporter/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ diff --git a/RollbarPLCrashReporter/Package.swift b/RollbarPLCrashReporter/Package.swift new file mode 100644 index 00000000..3a4b210b --- /dev/null +++ b/RollbarPLCrashReporter/Package.swift @@ -0,0 +1,78 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "RollbarPLCrashReporter", + platforms: [ + // Oldest targeted platform versions that are supported by this product. + .macOS(.v10_10), + .iOS(.v9), + .tvOS(.v11), + .watchOS(.v4), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "RollbarPLCrashReporter", + targets: ["RollbarPLCrashReporter"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + .package(name:"RollbarCommon", + path: "../RollbarCommon" + ), + .package(name:"PLCrashReporter", + url: "https://github.com/microsoft/plcrashreporter.git", + Package.Dependency.Requirement.branch("master") + ), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "RollbarPLCrashReporter", + dependencies: ["RollbarCommon", "PLCrashReporter"], + publicHeadersPath: "include", + cSettings: [ + .headerSearchPath("Sources/RollbarPLCrashReporter/**"), + // .headerSearchPath("Sources/RollbarPLCrashReporter"), + // .headerSearchPath("Sources/RollbarPLCrashReporter/include"), + // .headerSearchPath("Sources/RollbarPLCrashReporter/DTOs"), + + // .define("DEFINES_MODULE"), + ] + ), + .testTarget( + name: "RollbarPLCrashReporterTests", + dependencies: ["RollbarPLCrashReporter"], + cSettings: [ + .headerSearchPath("Tests/RollbarKSCrashTests/**"), + // .headerSearchPath("Sources/RollbarKSCrash"), + // .headerSearchPath("Sources/RollbarKSCrash/include"), + // .headerSearchPath("Sources/RollbarKSCrash/DTOs"), + + // .define("DEFINES_MODULE"), + ] + ), + .testTarget( + name: "RollbarPLCrashReporterTests-ObjC", + dependencies: ["RollbarPLCrashReporter"], + cSettings: [ + .headerSearchPath("Tests/RollbarPLCrashReporterTests-ObjC/**"), + // .headerSearchPath("Sources/RollbarKSCrash"), + // .headerSearchPath("Sources/RollbarKSCrash/include"), + // .headerSearchPath("Sources/RollbarKSCrash/DTOs"), + + // .define("DEFINES_MODULE"), + ] + ), + ], + swiftLanguageVersions: [ + SwiftVersion.v4, + SwiftVersion.v4_2, + SwiftVersion.v5, + ] +) diff --git a/RollbarPLCrashReporter/README.md b/RollbarPLCrashReporter/README.md new file mode 100644 index 00000000..1e3fb3ef --- /dev/null +++ b/RollbarPLCrashReporter/README.md @@ -0,0 +1,3 @@ +# RollbarPLCrashReporter + +A description of this package. diff --git a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashReporter.swift b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashReporter.swift new file mode 100644 index 00000000..5ed4a5e7 --- /dev/null +++ b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashReporter.swift @@ -0,0 +1,3 @@ +struct RollbarPLCrashReporter { + var text = "Hello, World!" +} diff --git a/RollbarPLCrashReporter/Tests/LinuxMain.swift b/RollbarPLCrashReporter/Tests/LinuxMain.swift new file mode 100644 index 00000000..f982a071 --- /dev/null +++ b/RollbarPLCrashReporter/Tests/LinuxMain.swift @@ -0,0 +1,7 @@ +import XCTest + +import RollbarPLCrashReporterTests + +var tests = [XCTestCaseEntry]() +tests += RollbarPLCrashReporterTests.allTests() +XCTMain(tests) diff --git a/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests/RollbarPLCrashReporterTests.swift b/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests/RollbarPLCrashReporterTests.swift new file mode 100644 index 00000000..7957bf2c --- /dev/null +++ b/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests/RollbarPLCrashReporterTests.swift @@ -0,0 +1,15 @@ +import XCTest +@testable import RollbarPLCrashReporter + +final class RollbarPLCrashReporterTests: XCTestCase { + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + XCTAssertEqual(RollbarPLCrashReporter().text, "Hello, World!") + } + + static var allTests = [ + ("testExample", testExample), + ] +} diff --git a/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests/XCTestManifests.swift b/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests/XCTestManifests.swift new file mode 100644 index 00000000..d18e782f --- /dev/null +++ b/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests/XCTestManifests.swift @@ -0,0 +1,9 @@ +import XCTest + +#if !canImport(ObjectiveC) +public func allTests() -> [XCTestCaseEntry] { + return [ + testCase(RollbarPLCrashReporterTests.allTests), + ] +} +#endif diff --git a/RollbarSDK.xcworkspace/contents.xcworkspacedata b/RollbarSDK.xcworkspace/contents.xcworkspacedata index 4ced4179..7bbb3749 100644 --- a/RollbarSDK.xcworkspace/contents.xcworkspacedata +++ b/RollbarSDK.xcworkspace/contents.xcworkspacedata @@ -50,6 +50,9 @@ + + diff --git a/RollbarSDK.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/RollbarSDK.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/RollbarSDK.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved b/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved index c586b0e8..aee06228 100644 --- a/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -9,6 +9,15 @@ "revision": "64229cfa482d135c109dc3c66db7b30d1da855fc", "version": null } + }, + { + "package": "PLCrashReporter", + "repositoryURL": "https://github.com/microsoft/plcrashreporter.git", + "state": { + "branch": "master", + "revision": "ac7fe54ff8ecce90301708eef0f85bf1ba1d747e", + "version": null + } } ] }, From e177d74c7d4bd59f6b94fccc02687fc58cf9856a Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Thu, 17 Dec 2020 17:43:47 -0800 Subject: [PATCH 02/13] added RolbarPLCrashReporter podspec and updated other podspects --- RollbarCommon.podspec | 2 +- RollbarDeploys.podspec | 2 +- RollbarKSCrash.podspec | 2 +- RollbarNotifier.podspec | 2 +- RollbarPLCrashReporter.podspec | 64 +++++++++++++++++++ RollbarSDK.podspec | 2 +- .../contents.xcworkspacedata | 3 + 7 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 RollbarPLCrashReporter.podspec diff --git a/RollbarCommon.podspec b/RollbarCommon.podspec index 1fb518a8..9d445154 100644 --- a/RollbarCommon.podspec +++ b/RollbarCommon.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.version = "2.0.0-alpha27" s.name = "RollbarCommon" - s.summary = "Application or client side SDK for accessing the Rollbar API Server." + s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC Find, fix, and resolve errors with Rollbar. Easily send error data using Rollbar API. diff --git a/RollbarDeploys.podspec b/RollbarDeploys.podspec index d581da67..1e1908bf 100644 --- a/RollbarDeploys.podspec +++ b/RollbarDeploys.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.version = "2.0.0-alpha27" s.name = "RollbarDeploys" - s.summary = "Application or client side SDK for accessing the Rollbar API Server." + s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC Find, fix, and resolve errors with Rollbar. Easily send error data using Rollbar API. diff --git a/RollbarKSCrash.podspec b/RollbarKSCrash.podspec index 3944bfce..3e78dea4 100644 --- a/RollbarKSCrash.podspec +++ b/RollbarKSCrash.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.version = "2.0.0-alpha27" s.name = "RollbarKSCrash" - s.summary = "Application or client side SDK for accessing the Rollbar API Server." + s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC Find, fix, and resolve errors with Rollbar. Easily send error data using Rollbar API. diff --git a/RollbarNotifier.podspec b/RollbarNotifier.podspec index bfc4c26d..61de9ebf 100644 --- a/RollbarNotifier.podspec +++ b/RollbarNotifier.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.version = "2.0.0-alpha27" s.name = "RollbarNotifier" - s.summary = "Application or client side SDK for accessing the Rollbar API Server." + s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC Find, fix, and resolve errors with Rollbar. Easily send error data using Rollbar API. diff --git a/RollbarPLCrashReporter.podspec b/RollbarPLCrashReporter.podspec new file mode 100644 index 00000000..83dd5786 --- /dev/null +++ b/RollbarPLCrashReporter.podspec @@ -0,0 +1,64 @@ +# +# Be sure to run `pod spec lint RollbarPLCrashReporter.podspec' to ensure this is a valid spec. +# +# To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html +# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ +# + +Pod::Spec.new do |s| + + s.version = "2.0.0-alpha27" + s.name = "RollbarPLCrashReporter" + s.summary = "Application or client side SDK for interacting with the Rollbar API Server." + s.description = <<-DESC + Find, fix, and resolve errors with Rollbar. + Easily send error data using Rollbar API. + Analyze, de-dupe, send alerts, and prepare the data for further analysis. + Search, sort, and prioritize via the Rollbar dashboard. + DESC + s.homepage = "https://rollbar.com" + # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" + s.license = { :type => "MIT", :file => "LICENSE" } + # s.license = "MIT (example)" + s.documentation_url = "https://docs.rollbar.com/docs/ios" + s.authors = { "Andrey Kornich (Wide Spectrum Computing LLC)" => "akornich@gmail.com", + "Rollbar" => "support@rollbar.com" } + # s.author = { "Andrey Kornich" => "akornich@gmail.com" } + # Or just: s.author = "Andrey Kornich" + s.social_media_url = "http://twitter.com/rollbar" + s.source = { :git => "https://github.com/rollbar/rollbar-apple.git", + :tag => "v#{s.version}" + } + s.resource = "rollbar-logo.png" + # s.resources = "Resources/*.png" + + # When using multiple platforms: + s.ios.deployment_target = "9.0" + s.osx.deployment_target = "10.10" + s.tvos.deployment_target = "11.0" + s.watchos.deployment_target = "4.0" + # Any platform, if omitted: + # s.platform = :ios + # s.platform = :ios, "5.0" + + s.source_files = "#{s.name}/Sources/#{s.name}/**/*.{h,m}" + s.public_header_files = "#{s.name}/Sources/#{s.name}/include/*.h" + s.module_map = "#{s.name}/Sources/#{s.name}/include/module.modulemap" + # s.exclude_files = "Classes/Exclude" + # s.preserve_paths = "FilesToSave", "MoreFilesToSave" + + s.framework = "Foundation" + s.dependency "RollbarCommon", "~> #{s.version}" + s.dependency "PLCrashReporter", "~> 1.8.1" + # s.frameworks = "SomeFramework", "AnotherFramework" + # s.library = "iconv" + # s.libraries = "iconv", "xml2" + # s.dependency "JSONKit", "~> 1.4" + + s.requires_arc = true + # s.xcconfig = { + # "USE_HEADERMAP" => "NO", + # "HEADER_SEARCH_PATHS" => "$(PODS_ROOT)/Sources/#{s.name}/**" + # } + +end diff --git a/RollbarSDK.podspec b/RollbarSDK.podspec index 3619c45a..80f41efb 100644 --- a/RollbarSDK.podspec +++ b/RollbarSDK.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |sdk| # ============ sdk.version = "2.0.0-alpha27" sdk.name = "RollbarSDK" - sdk.summary = "Application or client side SDK for accessing the Rollbar API Server." + s.summary = "Application or client side SDK for interacting with the Rollbar API Server." sdk.description = <<-DESC Find, fix, and resolve errors with Rollbar. Easily send error data using Rollbar API. diff --git a/RollbarSDK.xcworkspace/contents.xcworkspacedata b/RollbarSDK.xcworkspace/contents.xcworkspacedata index 7bbb3749..87d2b0ca 100644 --- a/RollbarSDK.xcworkspace/contents.xcworkspacedata +++ b/RollbarSDK.xcworkspace/contents.xcworkspacedata @@ -34,6 +34,9 @@ + + From 817357881e79bee720247cfbe2c0165cec67de9f Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Thu, 17 Dec 2020 17:49:54 -0800 Subject: [PATCH 03/13] updated RollbarPLCrashReporter project with ObjC tests --- .../RollbarPLCrashReporterTests.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests-ObjC/RollbarPLCrashReporterTests.m diff --git a/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests-ObjC/RollbarPLCrashReporterTests.m b/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests-ObjC/RollbarPLCrashReporterTests.m new file mode 100644 index 00000000..48a39c4a --- /dev/null +++ b/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests-ObjC/RollbarPLCrashReporterTests.m @@ -0,0 +1,16 @@ +// Copyright (c) 2018 Rollbar, Inc. All rights reserved. + +#import + +@import RollbarPLCrashReporter; + +@interface RollbarPLCrashReporterTests : XCTestCase +@end + +@implementation RollbarPLCrashReporterTests + +- (void)testBasics { +} + +@end + From 054fce3ced498b6dc0ce07530e9abc10142f5a4b Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Wed, 23 Dec 2020 00:38:48 -0800 Subject: [PATCH 04/13] recreated RollbarPLCreashReporter from scratch --- RollbarPLCrashReporter/Package.swift | 54 +------------------ .../RollbarPLCrashReporterTests.m | 16 ------ .../contents.xcworkspacedata | 6 +-- .../xcshareddata/WorkspaceSettings.xcsettings | 2 + .../xcshareddata/swiftpm/Package.resolved | 9 ---- 5 files changed, 7 insertions(+), 80 deletions(-) delete mode 100644 RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests-ObjC/RollbarPLCrashReporterTests.m diff --git a/RollbarPLCrashReporter/Package.swift b/RollbarPLCrashReporter/Package.swift index 3a4b210b..0ea57851 100644 --- a/RollbarPLCrashReporter/Package.swift +++ b/RollbarPLCrashReporter/Package.swift @@ -5,13 +5,6 @@ import PackageDescription let package = Package( name: "RollbarPLCrashReporter", - platforms: [ - // Oldest targeted platform versions that are supported by this product. - .macOS(.v10_10), - .iOS(.v9), - .tvOS(.v11), - .watchOS(.v4), - ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( @@ -21,58 +14,15 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), - .package(name:"RollbarCommon", - path: "../RollbarCommon" - ), - .package(name:"PLCrashReporter", - url: "https://github.com/microsoft/plcrashreporter.git", - Package.Dependency.Requirement.branch("master") - ), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( name: "RollbarPLCrashReporter", - dependencies: ["RollbarCommon", "PLCrashReporter"], - publicHeadersPath: "include", - cSettings: [ - .headerSearchPath("Sources/RollbarPLCrashReporter/**"), - // .headerSearchPath("Sources/RollbarPLCrashReporter"), - // .headerSearchPath("Sources/RollbarPLCrashReporter/include"), - // .headerSearchPath("Sources/RollbarPLCrashReporter/DTOs"), - - // .define("DEFINES_MODULE"), - ] - ), + dependencies: []), .testTarget( name: "RollbarPLCrashReporterTests", - dependencies: ["RollbarPLCrashReporter"], - cSettings: [ - .headerSearchPath("Tests/RollbarKSCrashTests/**"), - // .headerSearchPath("Sources/RollbarKSCrash"), - // .headerSearchPath("Sources/RollbarKSCrash/include"), - // .headerSearchPath("Sources/RollbarKSCrash/DTOs"), - - // .define("DEFINES_MODULE"), - ] - ), - .testTarget( - name: "RollbarPLCrashReporterTests-ObjC", - dependencies: ["RollbarPLCrashReporter"], - cSettings: [ - .headerSearchPath("Tests/RollbarPLCrashReporterTests-ObjC/**"), - // .headerSearchPath("Sources/RollbarKSCrash"), - // .headerSearchPath("Sources/RollbarKSCrash/include"), - // .headerSearchPath("Sources/RollbarKSCrash/DTOs"), - - // .define("DEFINES_MODULE"), - ] - ), - ], - swiftLanguageVersions: [ - SwiftVersion.v4, - SwiftVersion.v4_2, - SwiftVersion.v5, + dependencies: ["RollbarPLCrashReporter"]), ] ) diff --git a/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests-ObjC/RollbarPLCrashReporterTests.m b/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests-ObjC/RollbarPLCrashReporterTests.m deleted file mode 100644 index 48a39c4a..00000000 --- a/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests-ObjC/RollbarPLCrashReporterTests.m +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2018 Rollbar, Inc. All rights reserved. - -#import - -@import RollbarPLCrashReporter; - -@interface RollbarPLCrashReporterTests : XCTestCase -@end - -@implementation RollbarPLCrashReporterTests - -- (void)testBasics { -} - -@end - diff --git a/RollbarSDK.xcworkspace/contents.xcworkspacedata b/RollbarSDK.xcworkspace/contents.xcworkspacedata index 87d2b0ca..6affaaa9 100644 --- a/RollbarSDK.xcworkspace/contents.xcworkspacedata +++ b/RollbarSDK.xcworkspace/contents.xcworkspacedata @@ -1,6 +1,9 @@ + + @@ -53,9 +56,6 @@ - - diff --git a/RollbarSDK.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/RollbarSDK.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings index f9b0d7c5..a6f6fb21 100644 --- a/RollbarSDK.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ b/RollbarSDK.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -2,6 +2,8 @@ + IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded + PreviewsEnabled diff --git a/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved b/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved index aee06228..c586b0e8 100644 --- a/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -9,15 +9,6 @@ "revision": "64229cfa482d135c109dc3c66db7b30d1da855fc", "version": null } - }, - { - "package": "PLCrashReporter", - "repositoryURL": "https://github.com/microsoft/plcrashreporter.git", - "state": { - "branch": "master", - "revision": "ac7fe54ff8ecce90301708eef0f85bf1ba1d747e", - "version": null - } } ] }, From eb63ca90764813b66e9db05f1c3970bb9d4be3f7 Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Wed, 23 Dec 2020 00:41:24 -0800 Subject: [PATCH 05/13] changed positioning of the SDK modules within the workspace navigator --- RollbarSDK.xcworkspace/contents.xcworkspacedata | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RollbarSDK.xcworkspace/contents.xcworkspacedata b/RollbarSDK.xcworkspace/contents.xcworkspacedata index 6affaaa9..87d2b0ca 100644 --- a/RollbarSDK.xcworkspace/contents.xcworkspacedata +++ b/RollbarSDK.xcworkspace/contents.xcworkspacedata @@ -1,9 +1,6 @@ - - @@ -56,6 +53,9 @@ + + From d29b0e716d49233a9dfcb6b9a70b23db866118d6 Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Wed, 23 Dec 2020 00:58:51 -0800 Subject: [PATCH 06/13] generated RollbarPLCrashReporter's Xcode scheme --- .../xcschemes/RollbarPLCrashReporter.xcscheme | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 RollbarPLCrashReporter/.swiftpm/xcode/xcshareddata/xcschemes/RollbarPLCrashReporter.xcscheme diff --git a/RollbarPLCrashReporter/.swiftpm/xcode/xcshareddata/xcschemes/RollbarPLCrashReporter.xcscheme b/RollbarPLCrashReporter/.swiftpm/xcode/xcshareddata/xcschemes/RollbarPLCrashReporter.xcscheme new file mode 100644 index 00000000..45fb7456 --- /dev/null +++ b/RollbarPLCrashReporter/.swiftpm/xcode/xcshareddata/xcschemes/RollbarPLCrashReporter.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 3c1c96c6e718e818628bb7d25598bbba6a32c7cd Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Wed, 23 Dec 2020 01:15:25 -0800 Subject: [PATCH 07/13] fixed RollbarPLCrashReporter Xcode targets --- RollbarPLCrashReporter/Package.swift | 55 ++++++++++++++++++- .../RollbarPLCrashCollector.m | 46 ++++++++++++++++ .../RollbarPLCrashReporter.swift | 3 - .../includes/RollbarPLCrashCollector.h | 17 ++++++ .../includes/module.modulemap | 8 +++ .../RollbarPLCrashReporterTests.m | 16 ++++++ .../xcshareddata/swiftpm/Package.resolved | 9 +++ 7 files changed, 149 insertions(+), 5 deletions(-) create mode 100644 RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m delete mode 100644 RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashReporter.swift create mode 100644 RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/includes/RollbarPLCrashCollector.h create mode 100644 RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/includes/module.modulemap create mode 100644 RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests-ObjC/RollbarPLCrashReporterTests.m diff --git a/RollbarPLCrashReporter/Package.swift b/RollbarPLCrashReporter/Package.swift index 0ea57851..ca11ad4a 100644 --- a/RollbarPLCrashReporter/Package.swift +++ b/RollbarPLCrashReporter/Package.swift @@ -5,6 +5,13 @@ import PackageDescription let package = Package( name: "RollbarPLCrashReporter", + platforms: [ + // Oldest targeted platform versions that are supported by this product. + .macOS(.v10_10), + .iOS(.v9), + .tvOS(.v11), + .watchOS(.v4), + ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( @@ -14,15 +21,59 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), + .package(name:"RollbarCommon", + path: "../RollbarCommon" + ), + .package(name:"PLCrashReporter", + url: "https://github.com/microsoft/plcrashreporter.git", + Package.Dependency.Requirement.branch("master") + ), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( name: "RollbarPLCrashReporter", - dependencies: []), + dependencies: ["RollbarCommon", .product(name: "CrashReporter", package: "PLCrashReporter")], + publicHeadersPath: "include", + cSettings: [ + .headerSearchPath("Sources/RollbarPLCrashReporter/**"), + // .headerSearchPath("Sources/RollbarPLCrashReporter"), + // .headerSearchPath("Sources/RollbarPLCrashReporter/include"), + // .headerSearchPath("Sources/RollbarPLCrashReporter/DTOs"), + + // .define("DEFINES_MODULE"), + ] + ), .testTarget( name: "RollbarPLCrashReporterTests", - dependencies: ["RollbarPLCrashReporter"]), + dependencies: ["RollbarPLCrashReporter"], + cSettings: [ + .headerSearchPath("Tests/RollbarKSCrashTests/**"), + // .headerSearchPath("Sources/RollbarKSCrash"), + // .headerSearchPath("Sources/RollbarKSCrash/include"), + // .headerSearchPath("Sources/RollbarKSCrash/DTOs"), + + // .define("DEFINES_MODULE"), + ] + ), + .testTarget( + name: "RollbarPLCrashReporterTests-ObjC", + dependencies: ["RollbarPLCrashReporter"], + cSettings: [ + .headerSearchPath("Tests/RollbarPLCrashReporterTests-ObjC/**"), + // .headerSearchPath("Sources/RollbarKSCrash"), + // .headerSearchPath("Sources/RollbarKSCrash/include"), + // .headerSearchPath("Sources/RollbarKSCrash/DTOs"), + + // .define("DEFINES_MODULE"), + ] + ), + ], + swiftLanguageVersions: [ + SwiftVersion.v4, + SwiftVersion.v4_2, + SwiftVersion.v5, ] ) + diff --git a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m new file mode 100644 index 00000000..d2260f03 --- /dev/null +++ b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m @@ -0,0 +1,46 @@ +// +// RollbarPLCrashCollector.m +// +// +// Created by Andrey Kornich on 2020-12-21. +// + +#import "RollbarPLCrashCollector.h" +#import "RollbarCrashReportData.h" +//#import "RollbarKSCrashInstallation.h" +//#import "RollbarKSCrashReportSink.h" + +@implementation RollbarPLCrashCollector + ++ (void)initialize { + + if (self == [RollbarPLCrashCollector class]) { + //RollbarKSCrashInstallation *installation = [RollbarKSCrashInstallation sharedInstance]; + //[installation install]; + } +} + +- (void)collectCrashReportsWithObserver:(NSObject *)observer { + + NSMutableArray *crashReports = [[NSMutableArray alloc] init]; + +// RollbarKSCrashInstallation *installation = [RollbarKSCrashInstallation sharedInstance]; +// [installation sendAllReportsWithCompletion:^(NSArray *filteredReports, BOOL completed, NSError *error) { +// if (error) { +// RollbarSdkLog(@"Could not enable crash reporter: %@", [error localizedDescription]); +// } else if (completed) { +// //[notifier processSavedItems]; +// for (NSString *crashReport in filteredReports) { +// +// RollbarCrashReportData *crashReportData = +// [[RollbarCrashReportData alloc] initWithCrashReport:crashReport]; +// +// [crashReports addObject:crashReportData]; +// } +// } +// }]; + + [observer onCrashReportsCollectionCompletion:crashReports]; +} + +@end diff --git a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashReporter.swift b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashReporter.swift deleted file mode 100644 index 5ed4a5e7..00000000 --- a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashReporter.swift +++ /dev/null @@ -1,3 +0,0 @@ -struct RollbarPLCrashReporter { - var text = "Hello, World!" -} diff --git a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/includes/RollbarPLCrashCollector.h b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/includes/RollbarPLCrashCollector.h new file mode 100644 index 00000000..eb4ddfec --- /dev/null +++ b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/includes/RollbarPLCrashCollector.h @@ -0,0 +1,17 @@ +// +// RollbarPLCrashCollector.h +// +// +// Created by Andrey Kornich on 2020-12-21. +// + +@import Foundation; +@import RollbarCommon; + +NS_ASSUME_NONNULL_BEGIN + +@interface RollbarPLCrashCollector : RollbarCrashCollectorBase + +@end + +NS_ASSUME_NONNULL_END diff --git a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/includes/module.modulemap b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/includes/module.modulemap new file mode 100644 index 00000000..1cc60bd8 --- /dev/null +++ b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/includes/module.modulemap @@ -0,0 +1,8 @@ +module RollbarPLCrashReporter { + umbrella "." + + export * + module * { export * } + + requires objc +} diff --git a/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests-ObjC/RollbarPLCrashReporterTests.m b/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests-ObjC/RollbarPLCrashReporterTests.m new file mode 100644 index 00000000..48a39c4a --- /dev/null +++ b/RollbarPLCrashReporter/Tests/RollbarPLCrashReporterTests-ObjC/RollbarPLCrashReporterTests.m @@ -0,0 +1,16 @@ +// Copyright (c) 2018 Rollbar, Inc. All rights reserved. + +#import + +@import RollbarPLCrashReporter; + +@interface RollbarPLCrashReporterTests : XCTestCase +@end + +@implementation RollbarPLCrashReporterTests + +- (void)testBasics { +} + +@end + diff --git a/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved b/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved index c586b0e8..aee06228 100644 --- a/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -9,6 +9,15 @@ "revision": "64229cfa482d135c109dc3c66db7b30d1da855fc", "version": null } + }, + { + "package": "PLCrashReporter", + "repositoryURL": "https://github.com/microsoft/plcrashreporter.git", + "state": { + "branch": "master", + "revision": "ac7fe54ff8ecce90301708eef0f85bf1ba1d747e", + "version": null + } } ] }, From 2809ee3331f7161ceb03ee8b3e34faadda72b497 Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Wed, 23 Dec 2020 01:20:51 -0800 Subject: [PATCH 08/13] fixed RollbarPLCrashReporter build --- .../{includes => include}/RollbarPLCrashCollector.h | 0 .../RollbarPLCrashReporter/{includes => include}/module.modulemap | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/{includes => include}/RollbarPLCrashCollector.h (100%) rename RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/{includes => include}/module.modulemap (100%) diff --git a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/includes/RollbarPLCrashCollector.h b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/include/RollbarPLCrashCollector.h similarity index 100% rename from RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/includes/RollbarPLCrashCollector.h rename to RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/include/RollbarPLCrashCollector.h diff --git a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/includes/module.modulemap b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/include/module.modulemap similarity index 100% rename from RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/includes/module.modulemap rename to RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/include/module.modulemap From 3efd0a9e2ceedbf8e40f8804be3686f4123f4c67 Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Sat, 26 Dec 2020 00:05:33 -0800 Subject: [PATCH 09/13] first cut of PLCrashReporter integration --- .../RollbarPLCrashCollector.m | 83 +++++++++++++++---- 1 file changed, 66 insertions(+), 17 deletions(-) diff --git a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m index d2260f03..d1415341 100644 --- a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m +++ b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m @@ -4,6 +4,7 @@ // // Created by Andrey Kornich on 2020-12-21. // +@import CrashReporter; #import "RollbarPLCrashCollector.h" #import "RollbarCrashReportData.h" @@ -12,7 +13,7 @@ @implementation RollbarPLCrashCollector -+ (void)initialize { ++(void)initialize { if (self == [RollbarPLCrashCollector class]) { //RollbarKSCrashInstallation *installation = [RollbarKSCrashInstallation sharedInstance]; @@ -20,25 +21,73 @@ + (void)initialize { } } -- (void)collectCrashReportsWithObserver:(NSObject *)observer { +-(void)collectCrashReportsWithObserver:(NSObject *)observer { + + // Configure our reporter: + PLCrashReporterSignalHandlerType signalHandlerType = +#if !TARGET_OS_TV + PLCrashReporterSignalHandlerTypeMach; +#else + PLCrashReporterSignalHandlerTypeBSD; +#endif + + PLCrashReporterConfig *config = + [[PLCrashReporterConfig alloc] initWithSignalHandlerType: signalHandlerType + symbolicationStrategy: PLCrashReporterSymbolicationStrategyAll + ]; + PLCrashReporter *reporter = + [[PLCrashReporter alloc] initWithConfiguration: config]; + + + if (!reporter || ![reporter hasPendingCrashReport]) { + return; + } + + NSFileManager *fm = [NSFileManager defaultManager]; + NSError *error; + + NSArray *paths = + NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [paths objectAtIndex:0]; + if (![fm createDirectoryAtPath: documentsDirectory + withIntermediateDirectories: YES + attributes:nil + error: &error]) { + NSLog(@"Could not create documents directory: %@", error); + return; + } + + NSData *data = + [reporter loadPendingCrashReportDataAndReturnError: &error]; + if (data == nil) { + NSLog(@"Failed to load crash report data: %@", error); + return; + } + [reporter purgePendingCrashReport]; + + PLCrashReport *report = + [[PLCrashReport alloc] initWithData: data + error: &error]; + if (report == nil) { + NSLog(@"Failed to parse crash report: %@", error); + return; + } + + NSString *crashReport = + [PLCrashReportTextFormatter stringValueForCrashReport: report + withTextFormat: PLCrashReportTextFormatiOS]; + NSLog(@"%@", crashReport); + + if (!crashReport) { + return; + } NSMutableArray *crashReports = [[NSMutableArray alloc] init]; + + RollbarCrashReportData *crashReportData = + [[RollbarCrashReportData alloc] initWithCrashReport:crashReport]; -// RollbarKSCrashInstallation *installation = [RollbarKSCrashInstallation sharedInstance]; -// [installation sendAllReportsWithCompletion:^(NSArray *filteredReports, BOOL completed, NSError *error) { -// if (error) { -// RollbarSdkLog(@"Could not enable crash reporter: %@", [error localizedDescription]); -// } else if (completed) { -// //[notifier processSavedItems]; -// for (NSString *crashReport in filteredReports) { -// -// RollbarCrashReportData *crashReportData = -// [[RollbarCrashReportData alloc] initWithCrashReport:crashReport]; -// -// [crashReports addObject:crashReportData]; -// } -// } -// }]; + [crashReports addObject:crashReportData]; [observer onCrashReportsCollectionCompletion:crashReports]; } From ecda6dc5ebbc8fa98641e5f2af88df92df8d06bf Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Tue, 29 Dec 2020 17:39:40 -0800 Subject: [PATCH 10/13] first cut: working PLCrashReporter integration --- .../macosAppObjC.xcodeproj/project.pbxproj | 7 ++++ Demos/macosAppObjC/macosAppObjC/AppDelegate.m | 13 ++++-- .../RollbarPLCrashCollector.m | 41 ++++++++++--------- .../xcshareddata/swiftpm/Package.resolved | 4 +- 4 files changed, 41 insertions(+), 24 deletions(-) diff --git a/Demos/macosAppObjC/macosAppObjC.xcodeproj/project.pbxproj b/Demos/macosAppObjC/macosAppObjC.xcodeproj/project.pbxproj index 5015feab..74ce6382 100644 --- a/Demos/macosAppObjC/macosAppObjC.xcodeproj/project.pbxproj +++ b/Demos/macosAppObjC/macosAppObjC.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 55759A732477561100ED3F04 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 55759A722477561100ED3F04 /* Assets.xcassets */; }; 55759A762477561100ED3F04 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 55759A742477561100ED3F04 /* Main.storyboard */; }; 55759A792477561100ED3F04 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 55759A782477561100ED3F04 /* main.m */; }; + 55A02A60259AAAE40071D60D /* RollbarPLCrashReporter in Frameworks */ = {isa = PBXBuildFile; productRef = 55A02A5F259AAAE40071D60D /* RollbarPLCrashReporter */; }; 55FD0711247860F1000BBC22 /* RollbarDeploys in Frameworks */ = {isa = PBXBuildFile; productRef = 55FD0710247860F1000BBC22 /* RollbarDeploys */; }; 55FD07142478614B000BBC22 /* RollbarDeploysDemoClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 55FD07132478614B000BBC22 /* RollbarDeploysDemoClient.m */; }; /* End PBXBuildFile section */ @@ -38,6 +39,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 55A02A60259AAAE40071D60D /* RollbarPLCrashReporter in Frameworks */, 55684F5A2553981600F82F34 /* RollbarKSCrash in Frameworks */, 55FD0711247860F1000BBC22 /* RollbarDeploys in Frameworks */, 5547273924903EB7005018BD /* RollbarNotifier in Frameworks */, @@ -109,6 +111,7 @@ 55FD0710247860F1000BBC22 /* RollbarDeploys */, 5547273824903EB7005018BD /* RollbarNotifier */, 55684F592553981600F82F34 /* RollbarKSCrash */, + 55A02A5F259AAAE40071D60D /* RollbarPLCrashReporter */, ); productName = macosAppObjC; productReference = 55759A692477560D00ED3F04 /* macosAppObjC.app */; @@ -367,6 +370,10 @@ isa = XCSwiftPackageProductDependency; productName = RollbarKSCrash; }; + 55A02A5F259AAAE40071D60D /* RollbarPLCrashReporter */ = { + isa = XCSwiftPackageProductDependency; + productName = RollbarPLCrashReporter; + }; 55FD0710247860F1000BBC22 /* RollbarDeploys */ = { isa = XCSwiftPackageProductDependency; productName = RollbarDeploys; diff --git a/Demos/macosAppObjC/macosAppObjC/AppDelegate.m b/Demos/macosAppObjC/macosAppObjC/AppDelegate.m index 48ef02ed..6d922450 100644 --- a/Demos/macosAppObjC/macosAppObjC/AppDelegate.m +++ b/Demos/macosAppObjC/macosAppObjC/AppDelegate.m @@ -11,7 +11,13 @@ #import "RollbarDeploysDemoClient.h" @import RollbarNotifier; -@import RollbarKSCrash; +//@import RollbarKSCrash; +@import RollbarPLCrashReporter; + +__attribute__((noinline)) static void crashIt (void) { + /* Trigger a crash */ + ((char *)NULL)[1] = 0; +} @interface AppDelegate () @@ -51,8 +57,9 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // @throw NSInternalInconsistencyException; // [self performSelector:@selector(die_die)]; // [self performSelector:NSSelectorFromString(@"crashme:") withObject:nil afterDelay:10]; - assert(NO); + //assert(NO); //exit(0); + crashIt(); } @@ -72,7 +79,7 @@ - (void)initRollbar { config.destination.environment = @"samples"; config.customData = @{ @"someKey": @"someValue", }; // init Rollbar shared instance: - id crashCollector = [[RollbarKSCrashCollector alloc] init]; + id crashCollector = [[RollbarPLCrashCollector alloc] init]; [Rollbar initWithConfiguration:config crashCollector:crashCollector]; [Rollbar infoMessage:@"Rollbar is up and running! Enjoy your remote error and log monitoring..."]; diff --git a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m index d1415341..1d406329 100644 --- a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m +++ b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m @@ -13,33 +13,36 @@ @implementation RollbarPLCrashCollector +static PLCrashReporter *sharedPLCrashReporter = nil; + +(void)initialize { if (self == [RollbarPLCrashCollector class]) { - //RollbarKSCrashInstallation *installation = [RollbarKSCrashInstallation sharedInstance]; - //[installation install]; + // Configure our reporter: + PLCrashReporterSignalHandlerType signalHandlerType = +#if !TARGET_OS_TV + PLCrashReporterSignalHandlerTypeMach; +#else + PLCrashReporterSignalHandlerTypeBSD; +#endif + + PLCrashReporterConfig *config = + [[PLCrashReporterConfig alloc] initWithSignalHandlerType: signalHandlerType + symbolicationStrategy: PLCrashReporterSymbolicationStrategyAll + ]; + + sharedPLCrashReporter = + [[PLCrashReporter alloc] initWithConfiguration: config]; + + BOOL success = [sharedPLCrashReporter enableCrashReporter]; } } -(void)collectCrashReportsWithObserver:(NSObject *)observer { - // Configure our reporter: - PLCrashReporterSignalHandlerType signalHandlerType = -#if !TARGET_OS_TV - PLCrashReporterSignalHandlerTypeMach; -#else - PLCrashReporterSignalHandlerTypeBSD; -#endif - - PLCrashReporterConfig *config = - [[PLCrashReporterConfig alloc] initWithSignalHandlerType: signalHandlerType - symbolicationStrategy: PLCrashReporterSymbolicationStrategyAll - ]; - PLCrashReporter *reporter = - [[PLCrashReporter alloc] initWithConfiguration: config]; - if (!reporter || ![reporter hasPendingCrashReport]) { + if (!sharedPLCrashReporter || ![sharedPLCrashReporter hasPendingCrashReport]) { return; } @@ -58,12 +61,12 @@ -(void)collectCrashReportsWithObserver:(NSObject } NSData *data = - [reporter loadPendingCrashReportDataAndReturnError: &error]; + [sharedPLCrashReporter loadPendingCrashReportDataAndReturnError: &error]; if (data == nil) { NSLog(@"Failed to load crash report data: %@", error); return; } - [reporter purgePendingCrashReport]; + [sharedPLCrashReporter purgePendingCrashReport]; PLCrashReport *report = [[PLCrashReport alloc] initWithData: data diff --git a/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved b/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved index aee06228..99a99d90 100644 --- a/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/RollbarSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -6,7 +6,7 @@ "repositoryURL": "https://github.com/kstenerud/KSCrash.git", "state": { "branch": "master", - "revision": "64229cfa482d135c109dc3c66db7b30d1da855fc", + "revision": "498aa21d23541b0bb4990f8d3d20bea2c280a18b", "version": null } }, @@ -15,7 +15,7 @@ "repositoryURL": "https://github.com/microsoft/plcrashreporter.git", "state": { "branch": "master", - "revision": "ac7fe54ff8ecce90301708eef0f85bf1ba1d747e", + "revision": "280cf16a19d85b707b6cc9fc235dde7457f6f7cc", "version": null } } From 08886d3eac77881d4da146fb125cc0648fd1f1a2 Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Wed, 30 Dec 2020 12:40:07 -0800 Subject: [PATCH 11/13] RollbarPLCrashReporter code complete - RollbarPLCrashReporter code complete - some code cleanup --- Demos/macosAppObjC/macosAppObjC/AppDelegate.m | 8 ++++++-- RollbarCommon/README.md | 2 +- RollbarKSCrash/README.md | 3 ++- .../Sources/RollbarNotifier/RollbarLogger.m | 4 ---- RollbarPLCrashReporter/README.md | 2 +- .../RollbarPLCrashReporter/RollbarPLCrashCollector.m | 12 +++++++----- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Demos/macosAppObjC/macosAppObjC/AppDelegate.m b/Demos/macosAppObjC/macosAppObjC/AppDelegate.m index 6d922450..40d4d59a 100644 --- a/Demos/macosAppObjC/macosAppObjC/AppDelegate.m +++ b/Demos/macosAppObjC/macosAppObjC/AppDelegate.m @@ -11,6 +11,7 @@ #import "RollbarDeploysDemoClient.h" @import RollbarNotifier; + //@import RollbarKSCrash; @import RollbarPLCrashReporter; @@ -26,6 +27,7 @@ @interface AppDelegate () @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + // Insert code here to initialize your application [self initRollbar]; @@ -42,7 +44,6 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { context:nil ]; } - @try { [self callTroublemaker]; @@ -65,6 +66,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - (void)applicationWillTerminate:(NSNotification *)aNotification { + // Insert code here to tear down your application [Rollbar infoMessage:@"The hosting application is terminating..."]; @@ -79,7 +81,9 @@ - (void)initRollbar { config.destination.environment = @"samples"; config.customData = @{ @"someKey": @"someValue", }; // init Rollbar shared instance: - id crashCollector = [[RollbarPLCrashCollector alloc] init]; + id crashCollector = + //[[RollbarKSCrashCollector alloc] init]; + [[RollbarPLCrashCollector alloc] init]; [Rollbar initWithConfiguration:config crashCollector:crashCollector]; [Rollbar infoMessage:@"Rollbar is up and running! Enjoy your remote error and log monitoring..."]; diff --git a/RollbarCommon/README.md b/RollbarCommon/README.md index b2dcb916..2bc99646 100644 --- a/RollbarCommon/README.md +++ b/RollbarCommon/README.md @@ -1,5 +1,5 @@ # RollbarCommon -This is an SDK module declaring protocols and implementing classes/types commonly used across the other SDK modules. +This is an SDK module declaring abstractions/conepts (protocols, abstract classes, etc.) and implementing classes/types commonly used across the other SDK modules. If any data type is used by more than one SDK module - place it here. diff --git a/RollbarKSCrash/README.md b/RollbarKSCrash/README.md index a3ba34f9..4ae10182 100644 --- a/RollbarKSCrash/README.md +++ b/RollbarKSCrash/README.md @@ -1,3 +1,4 @@ # RollbarKSCrash -This is an SDK module implementing integration with [KSCrash reporter](https://github.com/kstenerud/KSCrash). +This is an SDK module implements a RollbarCrashCollector based on the [KSCrash reporter](https://github.com/kstenerud/KSCrash). + diff --git a/RollbarNotifier/Sources/RollbarNotifier/RollbarLogger.m b/RollbarNotifier/Sources/RollbarNotifier/RollbarLogger.m index b3d3e1d0..6df1e55c 100644 --- a/RollbarNotifier/Sources/RollbarNotifier/RollbarLogger.m +++ b/RollbarNotifier/Sources/RollbarNotifier/RollbarLogger.m @@ -10,7 +10,6 @@ #import "RollbarThread.h" #import "RollbarReachability.h" #import -//#import "KSCrash.h" #import "RollbarTelemetry.h" #import "RollbarPayloadTruncator.h" #import "RollbarConfig.h" @@ -54,9 +53,6 @@ - (void)_test_doNothing; @end -//#define IS_IOS7_OR_HIGHER (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) -//#define IS_MACOS10_10_OR_HIGHER (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_10) - @implementation RollbarLogger { NSDate *nextSendTime; diff --git a/RollbarPLCrashReporter/README.md b/RollbarPLCrashReporter/README.md index 1e3fb3ef..16676b77 100644 --- a/RollbarPLCrashReporter/README.md +++ b/RollbarPLCrashReporter/README.md @@ -1,3 +1,3 @@ # RollbarPLCrashReporter -A description of this package. +This is an SDK module implements a RollbarCrashCollector based on the [PLCrashReporter] (https://github.com/microsoft/plcrashreporter.git). diff --git a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m index 1d406329..b4b42b12 100644 --- a/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m +++ b/RollbarPLCrashReporter/Sources/RollbarPLCrashReporter/RollbarPLCrashCollector.m @@ -5,11 +5,10 @@ // Created by Andrey Kornich on 2020-12-21. // @import CrashReporter; +@import RollbarCommon; #import "RollbarPLCrashCollector.h" #import "RollbarCrashReportData.h" -//#import "RollbarKSCrashInstallation.h" -//#import "RollbarKSCrashReportSink.h" @implementation RollbarPLCrashCollector @@ -18,6 +17,7 @@ @implementation RollbarPLCrashCollector +(void)initialize { if (self == [RollbarPLCrashCollector class]) { + // Configure our reporter: PLCrashReporterSignalHandlerType signalHandlerType = #if !TARGET_OS_TV @@ -25,23 +25,25 @@ +(void)initialize { #else PLCrashReporterSignalHandlerTypeBSD; #endif - PLCrashReporterConfig *config = [[PLCrashReporterConfig alloc] initWithSignalHandlerType: signalHandlerType symbolicationStrategy: PLCrashReporterSymbolicationStrategyAll ]; + // Allocate and init the PLCrashReporter: sharedPLCrashReporter = [[PLCrashReporter alloc] initWithConfiguration: config]; + // Enable the reporter: BOOL success = [sharedPLCrashReporter enableCrashReporter]; + if (!success) { + RollbarSdkLog(@"Couldn't enable PLCrashReporter!"); + } } } -(void)collectCrashReportsWithObserver:(NSObject *)observer { - - if (!sharedPLCrashReporter || ![sharedPLCrashReporter hasPendingCrashReport]) { return; } From f4fb74cf1c7b30bebd147216557b0de92b4560fd Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Wed, 30 Dec 2020 13:01:41 -0800 Subject: [PATCH 12/13] incremented SDK version --- README.md | 2 ++ RollbarCommon.podspec | 2 +- RollbarDeploys.podspec | 2 +- RollbarKSCrash.podspec | 2 +- RollbarNotifier.podspec | 2 +- RollbarNotifier/Sources/RollbarNotifier/DTOs/RollbarConfig.m | 2 +- RollbarPLCrashReporter.podspec | 2 +- RollbarSDK.podspec | 2 +- 8 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d3c41392..dbce6931 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,13 @@ All the active development will be done within this SDK repository. [![Platform](https://img.shields.io/cocoapods/p/RollbarDeploys.svg?label=RollbarDeploys)](https://docs.rollbar.com/docs/apple) [![Platform](https://img.shields.io/cocoapods/p/RollbarCommon.svg?label=RollbarCommon)](https://docs.rollbar.com/docs/apple) [![Platform](https://img.shields.io/cocoapods/p/RollbarKSCrash.svg?label=RollbarKSCrash)](https://docs.rollbar.com/docs/apple) +[![Platform](https://img.shields.io/cocoapods/p/RollbarPLCrashReporter.svg?label=RollbarPLCrashReporter)](https://docs.rollbar.com/docs/apple) [![CocoaPods](https://img.shields.io/cocoapods/v/RollbarNotifier?label=RollbarNotifier)](https://cocoapods.org/pods/RollbarNotifier) [![CocoaPods](https://img.shields.io/cocoapods/v/RollbarDeploys?label=RollbarDeploys)](https://cocoapods.org/pods/RollbarDeploys) [![CocoaPods](https://img.shields.io/cocoapods/v/RollbarCommon?label=RollbarCommon)](https://cocoapods.org/pods/RollbarCommon) [![CocoaPods](https://img.shields.io/cocoapods/v/RollbarKSCrash?label=RollbarKSCrash)](https://cocoapods.org/pods/RollbarKSCrash) +[![CocoaPods](https://img.shields.io/cocoapods/v/RollbarPLCrashReporter?label=RollbarPLCrashReporter)](https://cocoapods.org/pods/RollbarPLCrashReporter) ## Setup Instructions diff --git a/RollbarCommon.podspec b/RollbarCommon.podspec index 9d445154..155e3ccf 100644 --- a/RollbarCommon.podspec +++ b/RollbarCommon.podspec @@ -7,7 +7,7 @@ Pod::Spec.new do |s| - s.version = "2.0.0-alpha27" + s.version = "2.0.0-alpha28" s.name = "RollbarCommon" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC diff --git a/RollbarDeploys.podspec b/RollbarDeploys.podspec index 1e1908bf..11d3ec8a 100644 --- a/RollbarDeploys.podspec +++ b/RollbarDeploys.podspec @@ -7,7 +7,7 @@ Pod::Spec.new do |s| - s.version = "2.0.0-alpha27" + s.version = "2.0.0-alpha28" s.name = "RollbarDeploys" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC diff --git a/RollbarKSCrash.podspec b/RollbarKSCrash.podspec index 3e78dea4..63e2a717 100644 --- a/RollbarKSCrash.podspec +++ b/RollbarKSCrash.podspec @@ -7,7 +7,7 @@ Pod::Spec.new do |s| - s.version = "2.0.0-alpha27" + s.version = "2.0.0-alpha28" s.name = "RollbarKSCrash" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC diff --git a/RollbarNotifier.podspec b/RollbarNotifier.podspec index 61de9ebf..b521bcd3 100644 --- a/RollbarNotifier.podspec +++ b/RollbarNotifier.podspec @@ -7,7 +7,7 @@ Pod::Spec.new do |s| - s.version = "2.0.0-alpha27" + s.version = "2.0.0-alpha28" s.name = "RollbarNotifier" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC diff --git a/RollbarNotifier/Sources/RollbarNotifier/DTOs/RollbarConfig.m b/RollbarNotifier/Sources/RollbarNotifier/DTOs/RollbarConfig.m index d55ba80b..618a5d31 100644 --- a/RollbarNotifier/Sources/RollbarNotifier/DTOs/RollbarConfig.m +++ b/RollbarNotifier/Sources/RollbarNotifier/DTOs/RollbarConfig.m @@ -22,7 +22,7 @@ #pragma mark - constants -static NSString * const NOTIFIER_VERSION = @"2.0.0-alpha27"; +static NSString * const NOTIFIER_VERSION = @"2.0.0-alpha28"; static NSString * const NOTIFIER_NAME = @"rollbar-apple"; diff --git a/RollbarPLCrashReporter.podspec b/RollbarPLCrashReporter.podspec index 83dd5786..d46ac484 100644 --- a/RollbarPLCrashReporter.podspec +++ b/RollbarPLCrashReporter.podspec @@ -7,7 +7,7 @@ Pod::Spec.new do |s| - s.version = "2.0.0-alpha27" + s.version = "2.0.0-alpha28" s.name = "RollbarPLCrashReporter" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC diff --git a/RollbarSDK.podspec b/RollbarSDK.podspec index 80f41efb..58f71b68 100644 --- a/RollbarSDK.podspec +++ b/RollbarSDK.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |sdk| # Rollbar SDK: # ============ - sdk.version = "2.0.0-alpha27" + sdk.version = "2.0.0-alpha28" sdk.name = "RollbarSDK" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." sdk.description = <<-DESC From 380f17210162b0ef194470e7d0e793d94545c1db Mon Sep 17 00:00:00 2001 From: Andrey Kornich Date: Wed, 30 Dec 2020 20:06:20 -0800 Subject: [PATCH 13/13] fixing a typo --- RollbarCommon/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RollbarCommon/README.md b/RollbarCommon/README.md index 2bc99646..b94d4202 100644 --- a/RollbarCommon/README.md +++ b/RollbarCommon/README.md @@ -1,5 +1,5 @@ # RollbarCommon -This is an SDK module declaring abstractions/conepts (protocols, abstract classes, etc.) and implementing classes/types commonly used across the other SDK modules. +This is an SDK module declaring abstractions/concepts (protocols, abstract classes, etc.) and implementing classes/types commonly used across the other SDK modules. If any data type is used by more than one SDK module - place it here.