From caa6c99a40b3003f64dae5fe07afe75a5c6c07e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ru=CC=88diger=20Wei=C3=9F?= Date: Fri, 27 Jun 2025 20:53:32 +0200 Subject: [PATCH] Remove EOL SDK helper directories - Remove AppCenter/ (end-of-life service) - Remove HockeyApp/ (deprecated, replaced by AppCenter) - Remove Buglife/ (end-of-life service) - Remove Sentry/ (SMF server instance no longer exists) These SDK helpers are no longer functional and were already removed from documentation in the previous commit. --- AppCenter/AppCenterSDK+HiDrive.swift | 202 ---------------------- AppCenter/AppCenterSDK+SMFLogger.swift | 111 ------------ Buglife/BuglifeSDK.swift | 29 ---- HockeyApp/HockeySDK+SMFLogger-macOS.swift | 151 ---------------- HockeyApp/HockeySDK+SMFLogger.swift | 157 ----------------- HockeyApp/HockeySDK.swift | 85 --------- Sentry/SentrySDK+SMFLogger.swift | 176 ------------------- Sentry/SentrySDK.swift | 102 ----------- 8 files changed, 1013 deletions(-) delete mode 100644 AppCenter/AppCenterSDK+HiDrive.swift delete mode 100644 AppCenter/AppCenterSDK+SMFLogger.swift delete mode 100644 Buglife/BuglifeSDK.swift delete mode 100644 HockeyApp/HockeySDK+SMFLogger-macOS.swift delete mode 100644 HockeyApp/HockeySDK+SMFLogger.swift delete mode 100644 HockeyApp/HockeySDK.swift delete mode 100644 Sentry/SentrySDK+SMFLogger.swift delete mode 100644 Sentry/SentrySDK.swift diff --git a/AppCenter/AppCenterSDK+HiDrive.swift b/AppCenter/AppCenterSDK+HiDrive.swift deleted file mode 100644 index 9ea4407..0000000 --- a/AppCenter/AppCenterSDK+HiDrive.swift +++ /dev/null @@ -1,202 +0,0 @@ -// -// AppCenterSDK+SMFLogger.swift -// SmartMobileFactory -// -// Created by Konstantin Deichmann on 11.09.19. -// Copyright © 2019 SmartMobileFactory. All rights reserved. -// - -import Foundation -import AppCenter -import AppCenterCrashes -#if !os(macOS) -import AppCenterDistribute -#endif -import SMFLogger - - -fileprivate enum AppCenterConstants { - - static let appSecretKey = "AppCenterAppSecret" - static let smfLogUploadMaxCharCount = 1_500_000 // With 1_500_000 chars we'll be at 1.5MB~ - static let crashLogFileName = "SMFLogger.log" -} - -class AppCenterSDK: NSObject { - - // MARK: - Private static properties - - fileprivate static let isDebugBuild : Bool = { - #if DEBUG - return true - #else - return false - #endif - }() - - // MARK: - Private properties - - fileprivate static var delegate : AppCenterSDKDelegate? - - // MARK: - Public properties - - static var wasInitialized : Bool { - return AppCenter.isConfigured - } - - // MARK: - Methods - - /// This will setup the AppCenterSDK with the common base configuration. Crashes will be detected if the app is build with the release build type. - /// Distribution can be enabled using the configuration - /// - /// - Parameters: - /// - configuration: Configuration object - static func setup(configuration: AppCenterSDK.Configuration = .default) { - guard (self.isDebugBuild == false || configuration.enableDebug == true) else { - return - } - - self.delegate = AppCenterSDKDelegate(isLogUploadEnabled: configuration.isLogUploadEnabled) - - var services = [AnyClass]() - - #if !os(macOS) - if (configuration.isDistributionEnabled == true) { - services.append(Distribute.self) - } - #endif - - if (configuration.isCrashReportEnabled == true) { - services.append(Crashes.self) - } - - guard (services.isEmpty == false) else { - return - } - - AppCenter.start(withAppSecret: configuration.appSecret, services: services) - Crashes.enabled = configuration.isCrashReportEnabled - Crashes.delegate = self.delegate - } - - #if !os(macOS) - /// Returns True, if and only if the Service got started and is enabled. - static var isDistributionEnabled: Bool { - return Distribute.enabled - } - - /// Will enable or disable the Distribution Feature of AppCenter - /// While disabling works always. - /// For enabling the Setup (aka. start) - Method should be called before. - /// - /// Flow in the App, for Apps that want to dynamically change that State: - /// - Call the Setup Method for with `isDistributionEnabled` set to true. - /// - Disable Distribution using `enableDistribution(enabled: false)` - /// - Enable Distribution at a later time using the same method - /// - /// - Parameter enabled: Enable or Disable Distribtion - static func enableDistribution(enabled: Bool = true) { - Distribute.enabled = enabled - } - #endif - - /// Returns True, if and only if Crash Reporting is enabled. - static var isCrashReportingEnabled: Bool { - return Crashes.enabled - } - - /// Will enable or disable the sending od crash reports to AppCenter - /// While disabling works always. - /// For enabling the Setup (aka. start) - Method should be called before. - /// - /// Flow in the App, for Apps that want to dynamically change that State: - /// - Call the Setup Method for with `isDistributionEnabled` set to true. - /// - Disable Distribution using `enableDistribution(enabled: false)` - /// - Enable Distribution at a later time using the same method - /// - /// - Parameter enabled: Enable or Disable Distribtion - static func enableCrashReporting(enabled: Bool = true) { - Crashes.enabled = enabled - } - - /// This will create a `fatalError` to crash the app. - static func performTestCrash() { - - Crashes.generateTestCrash() - } -} - -extension AppCenterSDK { - - struct Configuration { - - fileprivate var enableDebug : Bool - fileprivate var appSecret : String - fileprivate var isDistributionEnabled : Bool - fileprivate var isCrashReportEnabled : Bool - fileprivate var isLogUploadEnabled : Bool - - /// Initializes a AppCenterSDK Configuration - /// - /// - Parameters: - /// - appSecret: supply this manually if you dont want it in the info.plist - /// - enableDebug: Should start the Services even for Debug, Default is false - /// - isDistributionEnabled: Should start the Distribution Service, Default is false for Debug and Live apps, else true - /// - isCrashReportEnabled: enables sending of crash reports, Default is true - /// - isLogUploadEnabled: enables attachment of logs to crash reports, Default is true - init(appSecret: String? = nil, enableDebug: Bool = false, isDistributionEnabled: Bool? = nil, isCrashReportEnabled: Bool = true, isLogUploadEnabled: Bool = true) { - - let appSecretFromBundle = Bundle.main.object(forInfoDictionaryKey: AppCenterConstants.appSecretKey) as? String - - guard let _appSecret = (appSecret ?? appSecretFromBundle) else { - fatalError("You have to set the `\(AppCenterConstants.appSecretKey)` key in the info plist or specify your own when initializing the SDK.") - } - - self.enableDebug = enableDebug - self.appSecret = _appSecret - self.isCrashReportEnabled = isCrashReportEnabled - self.isLogUploadEnabled = isLogUploadEnabled - - #if DEBUG - self.isDistributionEnabled = isDistributionEnabled ?? false - #elseif LIVE - self.isDistributionEnabled = isDistributionEnabled ?? false - #else - self.isDistributionEnabled = isDistributionEnabled ?? true - #endif - } - - static var `default`: AppCenterSDK.Configuration { - return Configuration() - } - } -} - -private class AppCenterSDKDelegate : NSObject, CrashesDelegate { - - private var isLogUploadEnabled : Bool - - init(isLogUploadEnabled : Bool) { - self.isLogUploadEnabled = isLogUploadEnabled - } - - func attachments(with crashes: Crashes, for errorReport: ErrorReport) -> [ErrorAttachmentLog]? { - guard (self.isLogUploadEnabled == true) else { - return [] - } - - return [ErrorAttachmentLog.attachment(withText: self.applicationLog, filename: AppCenterConstants.crashLogFileName)] - } - - private var applicationLog: String { - guard - (self.isLogUploadEnabled == true), - let description = Logger.logFilesContent(maxSize: AppCenterConstants.smfLogUploadMaxCharCount), - (description.isEmpty == false) else { - return "No Log found" - } - - return description - } -} - diff --git a/AppCenter/AppCenterSDK+SMFLogger.swift b/AppCenter/AppCenterSDK+SMFLogger.swift deleted file mode 100644 index 24d9bc4..0000000 --- a/AppCenter/AppCenterSDK+SMFLogger.swift +++ /dev/null @@ -1,111 +0,0 @@ -// -// AppCenterSDK+SMFLogger.swift -// SmartMobileFactory -// -// Created by Konstantin Deichmann on 11.09.19. -// Copyright © 2019 SmartMobileFactory. All rights reserved. -// - -import Foundation -import AppCenter -import AppCenterDistribute - -fileprivate enum AppCenterConstants { - - static let appSecretKey = "AppCenterAppSecret" -} - -class AppCenterSDK: NSObject { - - // MARK: - Private static properties - - fileprivate static let isDebugBuild : Bool = { - #if DEBUG - return true - #else - return false - #endif - }() - - // MARK: - Public properties - - static var wasInitialized : Bool { - return AppCenter.isConfigured - } - - // MARK: - Methods - - /// This will setup the AppCenterSDK with the common base configuration. - /// Distribution can be enabled using the configuration - /// - /// - Parameters: - /// - configuration: Configuration object - static func setup(configuration: AppCenterSDK.Configuration = .default) { - guard (self.isDebugBuild == false || configuration.enableDebug == true) else { - return - } - - let services = (configuration.isDistributionEnabled == true) ? [Distribute.self] : [] - - AppCenter.start(withAppSecret: configuration.appSecret, services: services) - } - - /// Returns True, if and only if the Service got started and is enabled. - static var isDistributionEnabled: Bool { - return Distribute.enabled - } - - /// Will enable or disable the Distribution Feature of AppCenter - /// While disabling works always. - /// For enabling the Setup (aka. start) - Method should be called before. - /// - /// Flow in the App, for Apps that want to dynamically change that State: - /// - Call the Setup Method for with `isDistributionEnabled` set to true. - /// - Disable Distribution using `enableDistribution(enabled: false)` - /// - Enable Distribution at a later time using the same method - /// - /// - Parameter enabled: Enable or Disable Distribtion - static func enableDistribution(enabled: Bool = true) { - Distribute.enabled = enabled - } -} - -extension AppCenterSDK { - - struct Configuration { - - fileprivate var enableDebug : Bool - fileprivate var appSecret : String - fileprivate var isDistributionEnabled : Bool - - /// Initializes a AppCenterSDK Configuration - /// - /// - Parameters: - /// - appSecret: supply this manually if you dont want it in the info.plist - /// - enableDebug: Should start the Services even for Debug, Default is false - /// - isDistributionEnabled: Should start the Distribution Service, Default is false for Debug and Live apps, else true, - init(appSecret: String? = nil, enableDebug: Bool = false, isDistributionEnabled: Bool? = nil) { - - let appSecretFromBundle = Bundle.main.object(forInfoDictionaryKey: AppCenterConstants.appSecretKey) as? String - - guard let _appSecret = (appSecret ?? appSecretFromBundle) else { - fatalError("You have to set the `\(AppCenterConstants.appSecretKey)` key in the info plist or specify your own when initializing the SDK.") - } - - self.enableDebug = enableDebug - self.appSecret = _appSecret - - #if DEBUG - self.isDistributionEnabled = isDistributionEnabled ?? false - #elseif LIVE - self.isDistributionEnabled = isDistributionEnabled ?? false - #else - self.isDistributionEnabled = isDistributionEnabled ?? true - #endif - } - - static var `default`: AppCenterSDK.Configuration { - return Configuration() - } - } -} diff --git a/Buglife/BuglifeSDK.swift b/Buglife/BuglifeSDK.swift deleted file mode 100644 index bfc3ac8..0000000 --- a/Buglife/BuglifeSDK.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// BuglifeSDK.swift -// SMF-iOS-CommonProjectSetupFiles -// -// Created by Hanas Seiffert on 29/08/16. -// Copyright © 2016 Smart Mobile Factory. All rights reserved. -// - -import Foundation -import Buglife - -struct BuglifeSDK { - - static let identifierKey = "BuglifeId" - - /** - This will setup the Buglife SDK with the common base configuration. - - - parameter invocationOptions: The `LIFEInvocationOptions` to determine which invocation option should be used to trigger Buglife. The default is `.Shake`. - */ - static func setup(withOption invocationOptions: LIFEInvocationOptions = .shake) { - if let _identifier = Bundle.main.object(forInfoDictionaryKey: identifierKey) as? String { - Buglife.shared().start(withAPIKey: _identifier) - Buglife.shared().invocationOptions = invocationOptions - } else { - print("Warning: You have to the set the `\(identifierKey)` key in the info plist.") - } - } -} diff --git a/HockeyApp/HockeySDK+SMFLogger-macOS.swift b/HockeyApp/HockeySDK+SMFLogger-macOS.swift deleted file mode 100644 index 4c5a4f3..0000000 --- a/HockeyApp/HockeySDK+SMFLogger-macOS.swift +++ /dev/null @@ -1,151 +0,0 @@ -// -// HockeySDK.swift -// SMF-iOS-CommonProjectSetupFiles -// -// Created by Hanas Seiffert on 29/08/16. -// Copyright (c) 2016 Smart Mobile Factory. All rights reserved. -// - -import Foundation -import HockeySDK -import SMFLogger - -class HockeySDK: NSObject { - - // MARK: - Private static properties - - fileprivate static var shared : HockeySDK? - - fileprivate static let plistHockeyIDKey = "HockeyAppId" - - fileprivate static let isDebugBuild : Bool = { - #if DEBUG - return true - #else - return false - #endif - }() - - // MARK: - Private properties - - fileprivate var isInitialized = false - - fileprivate var configuration : HockeySDK.Configuration? - - // MARK: - Public properties - - static var wasInitialized : Bool { - return (HockeySDK.shared?.isInitialized ?? false) - } - - // MARK: - Initialization - - init(configuration: HockeySDK.Configuration) { - self.configuration = configuration - - super.init() - - HockeySDK.shared = self - } - - // MARK: - Methods - - /// This will setup the HockeySDK with the common base configuration. Crashes will be detected if the app is build with the release build type and the `HockeyAppId` token taken from the info plists. - /// - /// - Parameters: - /// - configuration: HockeySDK Configuration - static func setup(_ configuration: HockeySDK.Configuration) { - - // Get the HockeyApp identifier - let idFromConfiguration = configuration.hockeyAppID - let idFromPlist = Bundle.main.object(forInfoDictionaryKey: HockeySDK.plistHockeyIDKey) as? String - - guard let _identifierKey = (idFromConfiguration ?? idFromPlist) else { - assertionFailure("Error: You have to set the `\(HockeySDK.plistHockeyIDKey)` key in the info plist.") - return - } - - // Make sure HockeySDK is not setup in a debug build - guard (self.isDebugBuild == false) else { - // Configure HockeyApp only for non debug builds or if the exception flag is set to true - return - } - - let instance = (self.shared ?? HockeySDK(configuration: configuration)) - BITHockeyManager.shared().configure(withIdentifier: _identifierKey, delegate: instance) - BITHockeyManager.shared().crashManager.isAutoSubmitCrashReport = configuration.autoSubmitCrashReport - BITHockeyManager.shared().start() - - instance.isInitialized = true - } - - /// Modifies the autoSubmitCrashReport value. This method should be used to enable or disable crash reports during the app usage. - /// - /// - Parameters: - /// - autoSubmitCrashReport: Determines whether crashes should be send to HockeyApp and whether it should be done automatically or manually by the user. - static func updateAutoSubmitCrashReport(to autoSubmitCrashReport: Bool) { - guard (self.shared?.isInitialized == true) else { - assertionFailure("Error: You have to setup `HockeySDK` before updating the autoSubmitCrashReport. The update won't be performed.") - return - } - - BITHockeyManager.shared().crashManager.isAutoSubmitCrashReport = autoSubmitCrashReport - } - - /// This will create a `fatalError` to crash the app. - static func performTestCrash() { - guard (self.shared?.isInitialized == true) else { - assertionFailure("Error: You have to setup `HockeySDK` before performing a test crash. The test crash won't be performed otherwise.") - return - } - - fatalError("This is a test crash to trigger a crash report in the HockeyApp") - } -} - -// MARK: - HockeySDK.Configuration - -extension HockeySDK { - - struct Configuration { - fileprivate var hockeyAppID : String? - fileprivate var autoSubmitCrashReport : Bool - fileprivate var enableSMFLogUpload : Bool - fileprivate let smfLogUploadMaxSize : Int - - /// Initialized a HockeySDK Configuration - /// - /// - Parameters: - /// - hockeyAppID: The app's hockeyAppID - /// - autoSubmitCrashReport: true if the crash should be reported automatically. The default value is `true`. - /// - enableSMFLogUpload: true if you want the SMFLogger logs to be submitted with a crash - /// - smfLogUploadMaxSize: The max count of characters which should be uploaded - init(hockeyAppID: String? = nil, autoSubmitCrashReport: Bool = true, enableSMFLogUpload: Bool = true, smfLogUploadMaxSize: Int = 5000) { - self.hockeyAppID = hockeyAppID - self.enableSMFLogUpload = enableSMFLogUpload - self.smfLogUploadMaxSize = smfLogUploadMaxSize - self.autoSubmitCrashReport = autoSubmitCrashReport - } - - static var `default`: HockeySDK.Configuration { - return Configuration() - } - } -} - -// MARK: - BITHockeyManagerDelegate - -extension HockeySDK: BITHockeyManagerDelegate { - - func applicationLog(for crashManager: BITCrashManager!) -> String! { - guard - let configuration = self.configuration, - (configuration.enableSMFLogUpload == true), - let description = Logger.logFilesContent(maxSize: configuration.smfLogUploadMaxSize), - (description.isEmpty == false) else { - return nil - } - - return description - } -} diff --git a/HockeyApp/HockeySDK+SMFLogger.swift b/HockeyApp/HockeySDK+SMFLogger.swift deleted file mode 100644 index b0fc243..0000000 --- a/HockeyApp/HockeySDK+SMFLogger.swift +++ /dev/null @@ -1,157 +0,0 @@ -// -// HockeySDK.swift -// SMF-iOS-CommonProjectSetupFiles -// -// Created by Hanas Seiffert on 29/08/16. -// Copyright (c) 2016 Smart Mobile Factory. All rights reserved. -// - -import Foundation -import HockeySDK -import SMFLogger - -class HockeySDK: NSObject { - - // MARK: - Private static properties - - fileprivate static var shared : HockeySDK? - - fileprivate static let plistHockeyIDKey = "HockeyAppId" - - static let uiTestModeArgument = "SMF.UITestMode" - - fileprivate static let isDebugBuild : Bool = { - #if DEBUG - return true - #else - return false - #endif - }() - - // MARK: - Private properties - - fileprivate var isInitialized = false - - fileprivate var configuration : HockeySDK.Configuration? - - // MARK: - Public properties - - static var wasInitialized : Bool { - return (HockeySDK.shared?.isInitialized ?? false) - } - - // MARK: - Initialization - - init(configuration: HockeySDK.Configuration) { - self.configuration = configuration - - super.init() - - HockeySDK.shared = self - } - - // MARK: - Methods - - /// This will setup the HockeySDK with the common base configuration. Crashes will be detected if the app is build with the release build type and the `HockeyAppId` token taken from the info plists. - /// - /// - Parameters: - /// - configuration: HockeySDK Configuration - static func setup(_ configuration: HockeySDK.Configuration) { - - // Get the HockeyApp identifier - let idFromConfiguration = configuration.hockeyAppID - let idFromPlist = Bundle.main.object(forInfoDictionaryKey: HockeySDK.plistHockeyIDKey) as? String - - guard let _identifierKey = (idFromConfiguration ?? idFromPlist) else { - assertionFailure("Error: You have to set the `\(HockeySDK.plistHockeyIDKey)` key in the info plist.") - return - } - - // Make sure HockeySDK is not setup in a debug build - guard (self.isDebugBuild == false) else { - // Configure HockeyApp only for non debug builds or if the exception flag is set to true - return - } - - let instance = (self.shared ?? HockeySDK(configuration: configuration)) - BITHockeyManager.shared().configure(withIdentifier: _identifierKey, delegate: instance) - if (CommandLine.arguments.contains(uiTestModeArgument)) { - BITHockeyManager.shared().isUpdateManagerDisabled = true - } - BITHockeyManager.shared().start() - BITHockeyManager.shared().authenticator.authenticateInstallation() - BITHockeyManager.shared().crashManager.crashManagerStatus = configuration.crashManagerStatus - - instance.isInitialized = true - } - - /// Modifies the crash mananger status. This method should be used to enable or disable crash reports during the app usage. - /// - /// - Parameters: - /// - status: The `BITCrashManagerStatus` which determines whether crashes should be send to HockeyApp and whether it should be done automatically or manually by the user. The default value is `autoSend`. - static func updateCrashManagerStatus(to status: BITCrashManagerStatus) { - guard (self.shared?.isInitialized == true) else { - assertionFailure("Error: You have to setup `HockeySDK` before updating the crash manager status. The update won't be performed.") - return - } - - BITHockeyManager.shared().crashManager.crashManagerStatus = status - } - - /// This will create a `fatalError` to crash the app. - static func performTestCrash() { - guard (self.shared?.isInitialized == true) else { - assertionFailure("Error: You have to setup `HockeySDK` before performing a test crash. The test crash won't be performed otherwise.") - return - } - - fatalError("This is a test crash to trigger a crash report in the HockeyApp") - } -} - -// MARK: - HockeySDK.Configuration - -extension HockeySDK { - - struct Configuration { - fileprivate var hockeyAppID : String? - fileprivate var crashManagerStatus : BITCrashManagerStatus - fileprivate var enableSMFLogUpload : Bool - fileprivate let smfLogUploadMaxSize : Int - - /// Initialized a HockeySDK Configuration - /// - /// - Parameters: - /// - hockeyAppID: The app's hockeyAppID - /// - crashManagerStatus: initial crash manager status - /// - enableSMFLogUpload: true if you want the SMFLogger logs to be submitted with a crash - /// - smfLogUploadMaxSize: The max count of characters which should be uploaded - init(hockeyAppID: String? = nil, crashManagerStatus: BITCrashManagerStatus = .autoSend, enableSMFLogUpload: Bool = true, smfLogUploadMaxSize: Int = 5000) { - self.hockeyAppID = hockeyAppID - self.enableSMFLogUpload = enableSMFLogUpload - self.smfLogUploadMaxSize = smfLogUploadMaxSize - self.crashManagerStatus = crashManagerStatus - } - - static var `default`: HockeySDK.Configuration { - return Configuration() - } - } -} - -// MARK: - BITHockeyManagerDelegate - -extension HockeySDK: BITHockeyManagerDelegate { - - func applicationLog(for crashManager: BITCrashManager!) -> String! { - guard - let configuration = self.configuration, - (configuration.enableSMFLogUpload == true), - let description = Logger.logFilesContent(maxSize: configuration.smfLogUploadMaxSize), - (description.isEmpty == false) else { - return nil - } - - return description - } -} diff --git a/HockeyApp/HockeySDK.swift b/HockeyApp/HockeySDK.swift deleted file mode 100644 index f9ad149..0000000 --- a/HockeyApp/HockeySDK.swift +++ /dev/null @@ -1,85 +0,0 @@ -// -// HockeySDK.swift -// SMF-iOS-CommonProjectSetupFiles -// -// Created by Hanas Seiffert on 29/08/16. -// Copyright (c) 2016 Smart Mobile Factory. All rights reserved. -// - -import Foundation -import HockeySDK - -struct HockeySDK { - - // MARK: - Public Properties - - static let identifierKey = "HockeyAppId" - - static let uiTestModeArgument = "SMF.UITestMode" - - // MARK: - Private Properties - - private static var isInitialized = false - - fileprivate static var isDebugBuild: Bool { - #if DEBUG - return true - #else - return false - #endif - } - - // MARK: - Methods - - /** - This will setup the HockeySDK with the common base configuration. Crashes will be detected if the app is build with the release build type and the `HockeyAppId` token taken from the info plists. - - - parameter crashManagerStatus: The `BITCrashManagerStatus` which determines whether crashes should be send to HockeyApp and whether it should be done automatically or manually by the user. The default value is `AutoSend`. - - parameter configureHockeyAppAlsoForDebugBuildTypes: `Bool` which determines whether the HockeySDK should also be setup if the app is build with the `DEBUG` type. The Default value is `false`. - */ - static func setup(withStatus crashManagerStatus: BITCrashManagerStatus = .autoSend, configureHockeyAppAlsoForDebugBuildTypes: Bool = false) { - - guard let _identifierKey = Bundle.main.object(forInfoDictionaryKey: identifierKey) as? String else { - assertionFailure("Warning: You have to set the `\(identifierKey)` key in the info plist.") - return - } - - guard (configureHockeyAppAlsoForDebugBuildTypes == true || self.isDebugBuild == false) else { - // Configure HockeyApp only for non debug builds or if the exception flag is set to true - return - } - - BITHockeyManager.shared().configure(withIdentifier: _identifierKey) - if (CommandLine.arguments.contains(uiTestModeArgument)) { - BITHockeyManager.shared().isUpdateManagerDisabled = true - } - BITHockeyManager.shared().start() - BITHockeyManager.shared().authenticator.authenticateInstallation() - BITHockeyManager.shared().crashManager.crashManagerStatus = crashManagerStatus - - self.isInitialized = true - } - - /** - Modifies the crash mananger status. This method should be used to enable or disable crash reports during the app usage. - - - parameter crashManagerStatus: The `BITCrashManagerStatus` which determines whether crashes should be send to HockeyApp and whether it should be done automatically or manually by the user. The default value is `AutoSend`. - */ - static func updateCrashManagerStatus(to status: BITCrashManagerStatus) { - guard (self.isInitialized == true) else { - self.setup(withStatus: status, configureHockeyAppAlsoForDebugBuildTypes: false) - return - } - - BITHockeyManager.shared().crashManager.crashManagerStatus = status - } - - /** - This will create a `fatalError` to crash the app. - - - Warning: The app has to be build with the RELEASE build type or `configureHockeyAppAlsoForNonReleaseBuildTypes` set to `true` and no debugger can be attached in order the receive crash reports on HockeyApp. - */ - static func performTestCrash() { - fatalError("This is a test crash to trigger a crash report in the HockeyApp") - } -} diff --git a/Sentry/SentrySDK+SMFLogger.swift b/Sentry/SentrySDK+SMFLogger.swift deleted file mode 100644 index 47f72e8..0000000 --- a/Sentry/SentrySDK+SMFLogger.swift +++ /dev/null @@ -1,176 +0,0 @@ -// -// SentrySDK+SMFLogger.swift -// -// Copyright © 2019 Smart Mobile Factory. All rights reserved. -// - -import Foundation -import Sentry -import SMFLogger - -fileprivate struct SentryConstants { - - static let plistSentryDsn = "SentryDsn" - static let smfLogUploadMaxSizeDefault = 5000 -} - -class SMFSentrySDK: NSObject { - - // MARK: - Private static properties - - fileprivate static var shared : SMFSentrySDK? - - fileprivate static let isDebugBuild : Bool = { - #if DEBUG - return true - #else - return false - #endif - }() - - // MARK: - Private properties - - fileprivate var isInitialized = false - fileprivate var configuration : Configuration? - - // MARK: - Public properties - - static var wasInitialized : Bool { - return (SMFSentrySDK.shared?.isInitialized ?? false) - } - - // MARK: - Initialization - - override init() { - super.init() - - SMFSentrySDK.shared = self - } - - // MARK: - Methods - - /// This will setup the SentrySDK with the common base configuration. Crashes will be detected if the app is build with the release build type and the sentry dsn taken from the info plists. - /// - /// - Parameters: - /// - configuration: Configuration object - static func setup(configuration: SMFSentrySDK.Configuration) { - guard (self.isDebugBuild == false || configuration.enableDebug == true) else { - return - } - - let instance = (self.shared ?? SMFSentrySDK()) - - SentrySDK.start { (options: Options) in - options.dsn = configuration.sentryDSN - options.debug = configuration.enableDebug - options.beforeBreadcrumb = { (event: Breadcrumb?) in - if - (event?.level != .debug), - (configuration.enableSMFLogUpload == true), - let loggerContents = Logger.logFilesContent(maxSize: configuration.smfLogUploadMaxSize) { - event?.message = loggerContents - } - - return event - } - } - - instance.configuration = configuration - instance.isInitialized = true - } - - /// This will create a `fatalError` to crash the app. - static func performTestCrash() { - - guard (self.shared?.isInitialized == true) else { - assertionFailure("Error: You have to setup `SentrySDK` before performing a test crash. The test crash won't be performed otherwise.") - return - } - - SentrySDK.crash() - fatalError("This is a test crash to trigger a crash report in Sentry Dashboard") - } - - /// Send a custom event to Sentry for debugging. - /// - /// - Parameters: - /// - title : title of the event - /// - message : description of what happened - /// - additionalData : dictionary of key/value pairs that will apear under Additional Data in Sentry - /// - includeLoggerData : if the event should also include the last part of SMFLogger - /// - smfLogUploadMaxSize : The max count of characters which should be uploaded - static func sendEvent(title: String, message: String, additionalData: [String: Any]? = nil, includeLoggerData: Bool = true, smfLogUploadMaxSize: Int = (SMFSentrySDK.shared?.configuration?.smfLogUploadMaxSize ?? SentryConstants.smfLogUploadMaxSizeDefault)) { - let event = Event(level: .debug) - - if (additionalData != nil) { - event.extra = additionalData - } - - var fullMessage = "\(title) \n\n\(message)\n\n" - - if - (includeLoggerData == true), - let loggerContents = Logger.logFilesContent(maxSize: smfLogUploadMaxSize) { - fullMessage.append("--------- DEBUG LOG ---------\n\n") - fullMessage.append(loggerContents) - } - - event.message = SentryMessage(formatted: fullMessage) - - SentrySDK.capture(event: event) - } -} - -extension SMFSentrySDK { - - struct Configuration { - - fileprivate static let environment : String = { - #if ALPHA - return "alpha" - #endif - - #if BETA - return "beta" - #endif - - #if LIVE - return "live" - #endif - }() - - fileprivate var enableDebug : Bool = false - fileprivate var sentryDSN : String = "" - fileprivate var enableSMFLogUpload : Bool = true - fileprivate var enableBreadcrumbs : Bool = true - fileprivate var smfLogUploadMaxSize : Int = SentryConstants.smfLogUploadMaxSizeDefault - - /// Initializes a SentrySDK Configuration - /// - /// - Parameters: - /// - sentryDSN: supply this manually if you dont want it in the info.plist - /// - enableSMFLogUpload: true if you want the SMFLogger logs to be submitted with a crash - /// - enableBreadcrumbs: true if you want Sentry to attach the last user interaction before a crash - /// - smfLogUploadMaxSize: The max count of characters which should be uploaded - init(sentryDSN: String? = nil, enableSMFLogUpload: Bool = true, smfLogUploadMaxSize: Int = SentryConstants.smfLogUploadMaxSizeDefault, smfEnableBreadcrumbs: Bool = true, enableDebug: Bool = false) { - - // Get the Sentry DSN - let dsnFromPlist = Bundle.main.object(forInfoDictionaryKey: SentryConstants.plistSentryDsn) as? String - - guard let _sentryDsn = (sentryDSN ?? dsnFromPlist) else { - assertionFailure("Error: You have to set the `\(SentryConstants.plistSentryDsn)` key in the info plist or specify your own when initializing teh SDK.") - return - } - - self.enableDebug = enableDebug - self.sentryDSN = _sentryDsn - self.enableBreadcrumbs = smfEnableBreadcrumbs - self.enableSMFLogUpload = enableSMFLogUpload - self.smfLogUploadMaxSize = smfLogUploadMaxSize - } - - static var `default`: SMFSentrySDK.Configuration { - return Configuration() - } - } -} diff --git a/Sentry/SentrySDK.swift b/Sentry/SentrySDK.swift deleted file mode 100644 index f9fb50f..0000000 --- a/Sentry/SentrySDK.swift +++ /dev/null @@ -1,102 +0,0 @@ -// -// SentrySDK.swift -// -// Copyright © 2019 Smart Mobile Factory. All rights reserved. -// - -import Foundation -import Sentry - -class SentrySDK: NSObject { - - // MARK: - Private static properties - - fileprivate static var shared : SentrySDK? - - fileprivate static let plistSentryDsn = "SentryDsn" - - fileprivate static let isDebugBuild : Bool = { - #if DEBUG - return true - #else - return false - #endif - }() - - fileprivate static let environment : String = { - #if ALPHA - return "alpha" - #endif - - #if BETA - return "beta" - #endif - - #if LIVE - return "live" - #endif - }() - - // MARK: - Private properties - - fileprivate var isInitialized = false - - // MARK: - Public properties - - static var wasInitialized : Bool { - return (SentrySDK.shared?.isInitialized ?? false) - } - - // MARK: - Initialization - - override init() { - super.init() - - SentrySDK.shared = self - } - - // MARK: - Methods - - /// This will setup the SentrySDK with the common base configuration. Crashes will be detected if the app is build with the release build type and the sentry dsn taken from the info plists. - /// - /// - Parameters: - /// - configuration: sentry dsn string - static func setup(sentryDsn: String? = nil) { - - // Get the Sentry dsn - let idFromPlist = Bundle.main.object(forInfoDictionaryKey: SentrySDK.plistSentryDsn) as? String - - guard let _sentryDsn = (sentryDsn ?? idFromPlist) else { - assertionFailure("Error: You have to set the `\(SentrySDK.plistSentryDsn)` key in the info plist.") - return - } - - // Make sure SentrySDK is not setup in a debug build - guard (self.isDebugBuild == false) else { - // Configure SentrySDK only for non debug builds or if the exception flag is set to true - return - } - - let instance = (self.shared ?? SentrySDK()) - - Client.shared = try? Client(dsn: _sentryDsn) - Client.shared?.beforeSerializeEvent = { (event: Event) in - event.environment = self.environment - } - - try? Client.shared?.startCrashHandler() - instance.isInitialized = true - } - - /// This will create a `fatalError` to crash the app. - static func performTestCrash() { - - guard (self.shared?.isInitialized == true) else { - assertionFailure("Error: You have to setup `SentrySDK` before performing a test crash. The test crash won't be performed otherwise.") - return - } - - Client.shared?.reportUserException("TestCrash", reason: "Only testing crashes", language: "swift", lineOfCode: "23", stackTrace: [], logAllThreads: false, terminateProgram: true) - fatalError("This is a test crash to trigger a crash report in Sentry Dashboard") - } -}