diff --git a/plugins/2021.3660/iphone/libplugin_bugsnag.a b/plugins/2021.3660/iphone/libplugin_bugsnag.a index 9fdc5c3..55bcd9f 100644 Binary files a/plugins/2021.3660/iphone/libplugin_bugsnag.a and b/plugins/2021.3660/iphone/libplugin_bugsnag.a differ diff --git a/source/ios/Bugsnag.framework/Bugsnag b/source/ios/Bugsnag.framework/Bugsnag new file mode 100755 index 0000000..1ddf0e0 Binary files /dev/null and b/source/ios/Bugsnag.framework/Bugsnag differ diff --git a/source/ios/Bugsnag.framework/Headers/BSG_KSCrashReportWriter.h b/source/ios/Bugsnag.framework/Headers/BSG_KSCrashReportWriter.h new file mode 100644 index 0000000..f4f563c --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BSG_KSCrashReportWriter.h @@ -0,0 +1,238 @@ +// +// BSG_KSCrashReportWriter.h +// +// Created by Karl Stenerud on 2012-01-28. +// +// Copyright (c) 2012 Karl Stenerud. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall remain in place +// in this source code. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +/* Pointers to functions for writing to a crash report. All JSON types are + * supported. + */ + +#ifndef HDR_BSG_KSCrashReportWriter_h +#define HDR_BSG_KSCrashReportWriter_h + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** + * Encapsulates report writing functionality. + */ +typedef struct BSG_KSCrashReportWriter { + /** + * Add a boolean element to the report. + * + * @param writer This writer. + * + * @param name The name to give this element. + * + * @param value The value to add. + */ + void (*addBooleanElement)(const struct BSG_KSCrashReportWriter *writer, + const char *name, bool value); + + /** + * Add a floating point element to the report. + * + * @param writer This writer. + * + * @param name The name to give this element. + * + * @param value The value to add. + */ + void (*addFloatingPointElement)( + const struct BSG_KSCrashReportWriter *writer, const char *name, + double value); + + /** + * Add an integer element to the report. + * + * @param writer This writer. + * + * @param name The name to give this element. + * + * @param value The value to add. + */ + void (*addIntegerElement)(const struct BSG_KSCrashReportWriter *writer, + const char *name, long long value); + + /** + * Add an unsigned integer element to the report. + * + * @param writer This writer. + * + * @param name The name to give this element. + * + * @param value The value to add. + */ + void (*addUIntegerElement)(const struct BSG_KSCrashReportWriter *writer, + const char *name, unsigned long long value); + + /** + * Add a string element to the report. + * + * @param writer This writer. + * + * @param name The name to give this element. + * + * @param value The value to add. + */ + void (*addStringElement)(const struct BSG_KSCrashReportWriter *writer, + const char *name, const char *value); + + /** + * Add a string element from a text file to the report. + * + * @param writer This writer. + * + * @param name The name to give this element. + * + * @param filePath The path to the file containing the value to add. + */ + void (*addTextFileElement)(const struct BSG_KSCrashReportWriter *writer, + const char *name, const char *filePath); + + /** + * Add a JSON element from a text file to the report. + * + * @param writer This writer. + * + * @param name The name to give this element. + * + * @param filePath The path to the file containing the value to add. + */ + void (*addJSONFileElement)(const struct BSG_KSCrashReportWriter *writer, + const char *name, const char *filePath); + + /** + * Add a hex encoded data element to the report. + * + * @param writer This writer. + * + * @param name The name to give this element. + * + * @param value A pointer to the binary data. + * + * @param length The length of the data. + */ + void (*addDataElement)(const struct BSG_KSCrashReportWriter *writer, + const char *name, const char *value, + const size_t length); + + /** + * Begin writing a hex encoded data element to the report. + * + * @param writer This writer. + * + * @param name The name to give this element. + */ + void (*beginDataElement)(const struct BSG_KSCrashReportWriter *writer, + const char *name); + + /** + * Append hex encoded data to the current data element in the report. + * + * @param writer This writer. + * + * @param value A pointer to the binary data. + * + * @param length The length of the data. + */ + void (*appendDataElement)(const struct BSG_KSCrashReportWriter *writer, + const char *value, const size_t length); + + /** + * Complete writing a hex encoded data element to the report. + * + * @param writer This writer. + */ + void (*endDataElement)(const struct BSG_KSCrashReportWriter *writer); + + /** + * Add a UUID element to the report. + * + * @param writer This writer. + * + * @param name The name to give this element. + * + * @param value A pointer to the binary UUID data. + */ + void (*addUUIDElement)(const struct BSG_KSCrashReportWriter *writer, + const char *name, const unsigned char *value); + + /** + * Add a preformatted JSON element to the report. + * + * @param writer This writer. + * + * @param name The name to give this element. + * + * @param value A pointer to the JSON data. + */ + void (*addJSONElement)(const struct BSG_KSCrashReportWriter *writer, + const char *name, const char *jsonElement); + + /** + * Begin a new object container. + * + * @param writer This writer. + * + * @param name The name to give this element. + */ + void (*beginObject)(const struct BSG_KSCrashReportWriter *writer, + const char *name); + + /** + * Begin a new array container. + * + * @param writer This writer. + * + * @param name The name to give this element. + */ + void (*beginArray)(const struct BSG_KSCrashReportWriter *writer, + const char *name); + + /** + * Leave the current container, returning to the next higher level + * container. + * + * @param writer This writer. + */ + void (*endContainer)(const struct BSG_KSCrashReportWriter *writer); + + /** Internal contextual data for the writer */ + void *context; + +} BSG_KSCrashReportWriter; + +typedef void (*BSG_KSReportWriteCallback)( + const BSG_KSCrashReportWriter *writer); + +#ifdef __cplusplus +} +#endif + +#endif // HDR_KSCrashReportWriter_h diff --git a/source/ios/Bugsnag.framework/Headers/Bugsnag.h b/source/ios/Bugsnag.framework/Headers/Bugsnag.h new file mode 100644 index 0000000..26d9b8e --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/Bugsnag.h @@ -0,0 +1,386 @@ +// +// Bugsnag.h +// +// Created by Conrad Irwin on 2014-10-01. +// +// Copyright (c) 2014 Bugsnag, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall remain in place +// in this source code. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +#import + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + +/** + * Static access to a Bugsnag Client, the easiest way to use Bugsnag in your app. + */ +BUGSNAG_EXTERN +@interface Bugsnag : NSObject + +/** + * All Bugsnag access is class-level. Prevent the creation of instances. + */ +- (instancetype _Nonnull )init NS_UNAVAILABLE NS_SWIFT_UNAVAILABLE("Use class methods to initialise Bugsnag."); + +/** + * Start listening for crashes. + * + * This method initializes Bugsnag with the configuration set in your Info.plist. + * + * If a Bugsnag apiKey string has not been added to your Info.plist or is empty, an + * NSException will be thrown to indicate that the configuration is not valid. + * + * Once successfully initialized, NSExceptions, C++ exceptions, Mach exceptions and + * signals will be logged to disk before your app crashes. The next time your app + * launches, these reports will be sent to your Bugsnag dashboard. + */ ++ (BugsnagClient *_Nonnull)start; + +/** + * Start listening for crashes. + * + * This method initializes Bugsnag with the default configuration and the provided + * apiKey. + * + * If apiKey is nil or is empty, an NSException will be thrown to indicate that the + * configuration is not valid. + * + * Once successfully initialized, NSExceptions, C++ exceptions, Mach exceptions and + * signals will be logged to disk before your app crashes. The next time your app + * launches, these reports will be sent to your Bugsnag dashboard. + * + * @param apiKey The API key from your Bugsnag dashboard. + */ ++ (BugsnagClient *_Nonnull)startWithApiKey:(NSString *_Nonnull)apiKey; + +/** + * Start listening for crashes. + * + * This method initializes Bugsnag with the provided configuration object. + * + * If the configuration's apiKey is nil or is empty, an NSException will be thrown + * to indicate that the configuration is not valid. + * + * Once successfully initialized, NSExceptions, C++ exceptions, Mach exceptions and + * signals will be logged to disk before your app crashes. The next time your app + * launches, these reports will be sent to your Bugsnag dashboard. + * + * @param configuration The configuration to use. + */ ++ (BugsnagClient *_Nonnull)startWithConfiguration:(BugsnagConfiguration *_Nonnull)configuration; + +/** + * @return YES if Bugsnag has been started and the previous launch crashed + */ ++ (BOOL)appDidCrashLastLaunch BUGSNAG_DEPRECATED_WITH_REPLACEMENT("lastRunInfo.crashed"); + +/** + * Information about the last run of the app, and whether it crashed. + */ +@property (class, readonly, nullable, nonatomic) BugsnagLastRunInfo *lastRunInfo; + +/** + * Tells Bugsnag that your app has finished launching. + * + * Errors reported after calling this method will have the `BugsnagAppWithState.isLaunching` + * property set to false. + */ ++ (void)markLaunchCompleted; + +// ============================================================================= +// MARK: - Notify +// ============================================================================= + +/** + * Send a custom or caught exception to Bugsnag. + * + * The exception will be sent to Bugsnag in the background allowing your + * app to continue running. + * + * @param exception The exception. + */ ++ (void)notify:(NSException *_Nonnull)exception; + +/** + * Send a custom or caught exception to Bugsnag + * + * @param exception The exception + * @param block A block for optionally configuring the error report + */ ++ (void)notify:(NSException *_Nonnull)exception + block:(BugsnagOnErrorBlock _Nullable)block; + +/** + * Send an error to Bugsnag + * + * @param error The error + */ ++ (void)notifyError:(NSError *_Nonnull)error; + +/** + * Send an error to Bugsnag + * + * @param error The error + * @param block A block for optionally configuring the error report + */ ++ (void)notifyError:(NSError *_Nonnull)error + block:(BugsnagOnErrorBlock _Nullable)block; + +// ============================================================================= +// MARK: - Breadcrumbs +// ============================================================================= + +/** + * Leave a "breadcrumb" log message, representing an action that occurred + * in your app, to aid with debugging. + * + * @param message the log message to leave + */ ++ (void)leaveBreadcrumbWithMessage:(NSString *_Nonnull)message; + +/** + * Leave a "breadcrumb" log message each time a notification with a provided + * name is received by the application + * + * @param notificationName name of the notification to capture + */ ++ (void)leaveBreadcrumbForNotificationName:(NSString *_Nonnull)notificationName; + +/** + * Leave a "breadcrumb" log message, representing an action that occurred + * in your app, to aid with debugging, along with additional metadata and + * a type. + * + * @param message The log message to leave. + * @param metadata Diagnostic data relating to the breadcrumb. + * Values should be serializable to JSON with NSJSONSerialization. + * @param type A BSGBreadcrumbTypeValue denoting the type of breadcrumb. + */ ++ (void)leaveBreadcrumbWithMessage:(NSString *_Nonnull)message + metadata:(NSDictionary *_Nullable)metadata + andType:(BSGBreadcrumbType)type + NS_SWIFT_NAME(leaveBreadcrumb(_:metadata:type:)); + +/** + * Leave a "breadcrumb" log message representing a completed network request. + */ ++ (void)leaveNetworkRequestBreadcrumbForTask:(nonnull NSURLSessionTask *)task + metrics:(nonnull NSURLSessionTaskMetrics *)metrics + API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0)) + NS_SWIFT_NAME(leaveNetworkRequestBreadcrumb(task:metrics:)); + +/** + * Returns the current buffer of breadcrumbs that will be sent with captured events. This + * ordered list represents the most recent breadcrumbs to be captured up to the limit + * set in `BugsnagConfiguration.maxBreadcrumbs` + */ ++ (NSArray *_Nonnull)breadcrumbs; + +// ============================================================================= +// MARK: - Session +// ============================================================================= + +/** + * Starts tracking a new session. + * + * By default, sessions are automatically started when the application enters the foreground. + * If you wish to manually call startSession at + * the appropriate time in your application instead, the default behaviour can be disabled via + * autoTrackSessions. + * + * Any errors which occur in an active session count towards your application's + * stability score. You can prevent errors from counting towards your stability + * score by calling pauseSession and resumeSession at the appropriate + * time in your application. + * + * @see pauseSession: + * @see resumeSession: + */ ++ (void)startSession; + +/** + * Stops tracking a session. + * + * When a session is stopped, errors will not count towards your application's + * stability score. This can be advantageous if you do not wish these calculations to + * include a certain type of error, for example, a crash in a background service. + * You should disable automatic session tracking via autoTrackSessions if you call this method. + * + * A stopped session can be resumed by calling resumeSession, + * which will make any subsequent errors count towards your application's + * stability score. Alternatively, an entirely new session can be created by calling startSession. + * + * @see startSession: + * @see resumeSession: + */ ++ (void)pauseSession; + +/** + * Resumes a session which has previously been stopped, or starts a new session if none exists. + * + * If a session has already been resumed or started and has not been stopped, calling this + * method will have no effect. You should disable automatic session tracking via + * autoTrackSessions if you call this method. + * + * It's important to note that sessions are stored in memory for the lifetime of the + * application process and are not persisted on disk. Therefore calling this method on app + * startup would start a new session, rather than continuing any previous session. + * + * You should call this at the appropriate time in your application when you wish to + * resume a previously started session. Any subsequent errors which occur in your application + * will be reported to Bugsnag and will count towards your application's stability score. + * + * @see startSession: + * @see pauseSession: + * + * @return true if a previous session was resumed, false if a new session was started. + */ ++ (BOOL)resumeSession; + +// ============================================================================= +// MARK: - Other methods +// ============================================================================= + +/** + * Retrieves the context - a general summary of what was happening in the application + */ ++ (void)setContext:(NSString *_Nullable)context; + +/** + * Retrieves the context - a general summary of what was happening in the application + */ ++ (NSString *_Nullable)context; + +// ============================================================================= +// MARK: - User +// ============================================================================= + +/** + * The current user + */ ++ (BugsnagUser *_Nonnull)user; + +/** + * Set user metadata + * + * @param userId ID of the user + * @param name Name of the user + * @param email Email address of the user + * + * If user ID is nil, a Bugsnag-generated Device ID is used for the `user.id` property of events and sessions. + */ ++ (void)setUser:(NSString *_Nullable)userId + withEmail:(NSString *_Nullable)email + andName:(NSString *_Nullable)name; + +// ============================================================================= +// MARK: - Feature flags +// ============================================================================= + ++ (void)addFeatureFlagWithName:(nonnull NSString *)name variant:(nullable NSString *)variant + NS_SWIFT_NAME(addFeatureFlag(name:variant:)); + ++ (void)addFeatureFlagWithName:(nonnull NSString *)name + NS_SWIFT_NAME(addFeatureFlag(name:)); + ++ (void)addFeatureFlags:(nonnull NSArray *)featureFlags + NS_SWIFT_NAME(addFeatureFlags(_:)); + ++ (void)clearFeatureFlagWithName:(nonnull NSString *)name + NS_SWIFT_NAME(clearFeatureFlag(name:)); + ++ (void)clearFeatureFlags; + +// ============================================================================= +// MARK: - onSession +// ============================================================================= + +/** + * Add a callback to be invoked before a session is sent to Bugsnag. + * + * @param block A block which can modify the session + * + * @returns An opaque reference to the callback which can be passed to `removeOnSession:` + */ ++ (nonnull BugsnagOnSessionRef)addOnSessionBlock:(nonnull BugsnagOnSessionBlock)block + NS_SWIFT_NAME(addOnSession(block:)); + +/** + * Remove a callback that would be invoked before a session is sent to Bugsnag. + * + * @param callback The opaque reference of the callback, returned by `addOnSessionBlock:` + */ ++ (void)removeOnSession:(nonnull BugsnagOnSessionRef)callback + NS_SWIFT_NAME(removeOnSession(_:)); + +/** + * Deprecated + */ ++ (void)removeOnSessionBlock:(BugsnagOnSessionBlock _Nonnull)block + BUGSNAG_DEPRECATED_WITH_REPLACEMENT("removeOnSession:") + NS_SWIFT_NAME(removeOnSession(block:)); + +// ============================================================================= +// MARK: - onBreadcrumb +// ============================================================================= + +/** + * Add a callback to be invoked when a breadcrumb is captured by Bugsnag, to + * change the breadcrumb contents as needed + * + * @param block A block which returns YES if the breadcrumb should be captured + * + * @returns An opaque reference to the callback which can be passed to `removeOnBreadcrumb:` + */ ++ (nonnull BugsnagOnBreadcrumbRef)addOnBreadcrumbBlock:(nonnull BugsnagOnBreadcrumbBlock)block + NS_SWIFT_NAME(addOnBreadcrumb(block:)); + +/** + * Remove the callback that would be invoked when a breadcrumb is captured. + * + * @param callback The opaque reference of the callback, returned by `addOnBreadcrumbBlock:` + */ ++ (void)removeOnBreadcrumb:(nonnull BugsnagOnBreadcrumbRef)callback + NS_SWIFT_NAME(removeOnBreadcrumb(_:)); + +/** + * Deprecated + */ ++ (void)removeOnBreadcrumbBlock:(BugsnagOnBreadcrumbBlock _Nonnull)block + BUGSNAG_DEPRECATED_WITH_REPLACEMENT("removeOnBreadcrumb:") + NS_SWIFT_NAME(removeOnBreadcrumb(block:)); + +@end diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagApp.h b/source/ios/Bugsnag.framework/Headers/BugsnagApp.h new file mode 100644 index 0000000..4479b26 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagApp.h @@ -0,0 +1,60 @@ +// +// BugsnagApp.h +// Bugsnag +// +// Created by Jamie Lynch on 01/04/2020. +// Copyright © 2020 Bugsnag. All rights reserved. +// + +#import + +#import + +/** + * Stateless information set by the notifier about your app can be found on this class. These values + * can be accessed and amended if necessary. + */ +BUGSNAG_EXTERN +@interface BugsnagApp : NSObject + +/** + * The architecture of the running binary + */ +@property (copy, nullable, nonatomic) NSString *binaryArch; + +/** + * The bundle version used by the application + */ +@property (copy, nullable, nonatomic) NSString *bundleVersion; + +/** + * The revision ID from the manifest (React Native apps only) + */ +@property (copy, nullable, nonatomic) NSString *codeBundleId; + +/** + * Unique identifier for the debug symbols file corresponding to the application + */ +@property (copy, nullable, nonatomic) NSString *dsymUuid; + +/** + * The app identifier used by the application + */ +@property (copy, nullable, nonatomic) NSString *id; + +/** + * The release stage set in Configuration + */ +@property (copy, nullable, nonatomic) NSString *releaseStage; + +/** + * The application type set in Configuration + */ +@property (copy, nullable, nonatomic) NSString *type; + +/** + * The version of the application set in Configuration + */ +@property (copy, nullable, nonatomic) NSString *version; + +@end diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagAppWithState.h b/source/ios/Bugsnag.framework/Headers/BugsnagAppWithState.h new file mode 100644 index 0000000..2f6a231 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagAppWithState.h @@ -0,0 +1,42 @@ +// +// BugsnagAppWithState.h +// Bugsnag +// +// Created by Jamie Lynch on 01/04/2020. +// Copyright © 2020 Bugsnag. All rights reserved. +// + +#import + +#import +#import + +/** + * Stateful information set by the notifier about your app can be found on this class. These values + * can be accessed and amended if necessary. + */ +BUGSNAG_EXTERN +@interface BugsnagAppWithState : BugsnagApp + +/** + * The number of milliseconds the application was running before the event occurred + */ +@property (strong, nullable, nonatomic) NSNumber *duration; + +/** + * The number of milliseconds the application was running in the foreground before the + * event occurred + */ +@property (strong, nullable, nonatomic) NSNumber *durationInForeground; + +/** + * Whether the application was in the foreground when the event occurred + */ +@property (nonatomic) BOOL inForeground; + +/** + * Whether the app was still launching when the event occurred. + */ +@property (nonatomic) BOOL isLaunching; + +@end diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagBreadcrumb.h b/source/ios/Bugsnag.framework/Headers/BugsnagBreadcrumb.h new file mode 100644 index 0000000..e84c451 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagBreadcrumb.h @@ -0,0 +1,131 @@ +// +// BugsnagBreadcrumb.h +// +// Created by Delisa Mason on 9/16/15. +// +// Copyright (c) 2015 Bugsnag, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall remain in place +// in this source code. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +#import + +#import + +/** + * Types of breadcrumbs + */ +typedef NS_ENUM(NSUInteger, BSGBreadcrumbType) { + /** + * Any breadcrumb sent via Bugsnag.leaveBreadcrumb() + */ + BSGBreadcrumbTypeManual, + /** + * A call to Bugsnag.notify() (internal use only) + */ + BSGBreadcrumbTypeError, + /** + * A log message + */ + BSGBreadcrumbTypeLog, + /** + * A navigation action, such as pushing a view controller or dismissing an alert + */ + BSGBreadcrumbTypeNavigation, + /** + * A background process, such performing a database query + */ + BSGBreadcrumbTypeProcess, + /** + * A network request + */ + BSGBreadcrumbTypeRequest, + /** + * Change in application or view state + */ + BSGBreadcrumbTypeState, + /** + * A user event, such as authentication or control events + */ + BSGBreadcrumbTypeUser, +}; + +/** + * Types of breadcrumbs which can be reported + */ +typedef NS_OPTIONS(NSUInteger, BSGEnabledBreadcrumbType) { + BSGEnabledBreadcrumbTypeNone = 0, + BSGEnabledBreadcrumbTypeState = 1 << 1, + BSGEnabledBreadcrumbTypeUser = 1 << 2, + BSGEnabledBreadcrumbTypeLog = 1 << 3, + BSGEnabledBreadcrumbTypeNavigation = 1 << 4, + BSGEnabledBreadcrumbTypeRequest = 1 << 5, + BSGEnabledBreadcrumbTypeProcess = 1 << 6, + BSGEnabledBreadcrumbTypeError = 1 << 7, + BSGEnabledBreadcrumbTypeAll = BSGEnabledBreadcrumbTypeState + | BSGEnabledBreadcrumbTypeUser + | BSGEnabledBreadcrumbTypeLog + | BSGEnabledBreadcrumbTypeNavigation + | BSGEnabledBreadcrumbTypeRequest + | BSGEnabledBreadcrumbTypeProcess + | BSGEnabledBreadcrumbTypeError, +}; + +/** + * A short log message, representing an action that occurred in your app, to aid with debugging. + */ +@class BugsnagBreadcrumb; + +BUGSNAG_EXTERN +@interface BugsnagBreadcrumb : NSObject + +/** + * The date when the breadcrumb was left + */ +@property (readonly, nullable, nonatomic) NSDate *timestamp; + +/** + * The type of breadcrumb + */ +@property (readwrite, nonatomic) BSGBreadcrumbType type; + +/** + * The description of the breadcrumb + */ +@property (readwrite, copy, nonnull, nonatomic) NSString *message; + +/** + * Diagnostic data relating to the breadcrumb. + * + * The dictionary should be a valid JSON object. + */ +@property (readwrite, copy, nonnull, nonatomic) NSDictionary *metadata; + +@end + +#pragma mark - + +/// Internal protocol, not for public use. +/// Will be removed from public headers in next major release. +/// :nodoc: +@protocol BSGBreadcrumbSink + +- (void)leaveBreadcrumbWithMessage:(nonnull NSString *)message metadata:(nullable NSDictionary *)metadata andType:(BSGBreadcrumbType)type +NS_SWIFT_NAME(leaveBreadcrumb(_:metadata:type:)); + +@end diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagClient.h b/source/ios/Bugsnag.framework/Headers/BugsnagClient.h new file mode 100644 index 0000000..2f7c0da --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagClient.h @@ -0,0 +1,306 @@ +// +// BugsnagMetaData.m +// +// Created by Conrad Irwin on 2014-10-01. +// +// Copyright (c) 2014 Bugsnag, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall remain in place +// in this source code. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import + +#import +#import +#import +#import +#import +#import + +@class BugsnagSessionTracker; + +/** + * The BugsnagClient is not intended to be used directly. + * + * Use the static access provided by the Bugsnag class instead. + */ +BUGSNAG_EXTERN +@interface BugsnagClient : NSObject + +/** + * Initializes the client with the provided configuration. + */ +- (instancetype _Nonnull)initWithConfiguration:(BugsnagConfiguration *_Nonnull)configuration; + +// ============================================================================= +// MARK: - Notify +// ============================================================================= + +/** Send a custom or caught exception to Bugsnag. + * + * The exception will be sent to Bugsnag in the background allowing your + * app to continue running. + * + * @param exception The exception. + */ +- (void)notify:(NSException *_Nonnull)exception; + +/** + * Send a custom or caught exception to Bugsnag + * + * @param exception The exception + * @param block A block for optionally configuring the error report + */ +- (void)notify:(NSException *_Nonnull)exception + block:(BugsnagOnErrorBlock _Nullable)block; + +/** + * Send an error to Bugsnag + * + * @param error The error + */ +- (void)notifyError:(NSError *_Nonnull)error; + +/** + * Send an error to Bugsnag + * + * @param error The error + * @param block A block for optionally configuring the error report + */ +- (void)notifyError:(NSError *_Nonnull)error + block:(BugsnagOnErrorBlock _Nullable)block; + +// ============================================================================= +// MARK: - Breadcrumbs +// ============================================================================= + +/** + * Leave a "breadcrumb" log message, representing an action that occurred + * in your app, to aid with debugging. + * + * @param message the log message to leave + */ +- (void)leaveBreadcrumbWithMessage:(NSString *_Nonnull)message; + +/** + * Leave a "breadcrumb" log message each time a notification with a provided + * name is received by the application + * + * @param notificationName name of the notification to capture + */ +- (void)leaveBreadcrumbForNotificationName:(NSString *_Nonnull)notificationName; + +/** + * Leave a "breadcrumb" log message, representing an action that occurred + * in your app, to aid with debugging, along with additional metadata and + * a type. + * + * @param message The log message to leave. + * @param metadata Diagnostic data relating to the breadcrumb. + * Values should be serializable to JSON with NSJSONSerialization. + * @param type A BSGBreadcrumbTypeValue denoting the type of breadcrumb. + */ +- (void)leaveBreadcrumbWithMessage:(NSString *_Nonnull)message + metadata:(NSDictionary *_Nullable)metadata + andType:(BSGBreadcrumbType)type +NS_SWIFT_NAME(leaveBreadcrumb(_:metadata:type:)); + +/** + * Leave a "breadcrumb" log message representing a completed network request. + */ +- (void)leaveNetworkRequestBreadcrumbForTask:(nonnull NSURLSessionTask *)task + metrics:(nonnull NSURLSessionTaskMetrics *)metrics +API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0)) +NS_SWIFT_NAME(leaveNetworkRequestBreadcrumb(task:metrics:)); + +/** + * Returns the current buffer of breadcrumbs that will be sent with captured events. This + * ordered list represents the most recent breadcrumbs to be captured up to the limit + * set in `BugsnagConfiguration.maxBreadcrumbs` + */ +- (nonnull NSArray *)breadcrumbs; + +// ============================================================================= +// MARK: - Session +// ============================================================================= + +/** + * Starts tracking a new session. + * + * By default, sessions are automatically started when the application enters the foreground. + * If you wish to manually call startSession at + * the appropriate time in your application instead, the default behaviour can be disabled via + * autoTrackSessions. + * + * Any errors which occur in an active session count towards your application's + * stability score. You can prevent errors from counting towards your stability + * score by calling pauseSession and resumeSession at the appropriate + * time in your application. + * + * @see pauseSession: + * @see resumeSession: + */ +- (void)startSession; + +/** + * Stops tracking a session. + * + * When a session is stopped, errors will not count towards your application's + * stability score. This can be advantageous if you do not wish these calculations to + * include a certain type of error, for example, a crash in a background service. + * You should disable automatic session tracking via autoTrackSessions if you call this method. + * + * A stopped session can be resumed by calling resumeSession, + * which will make any subsequent errors count towards your application's + * stability score. Alternatively, an entirely new session can be created by calling startSession. + * + * @see startSession: + * @see resumeSession: + */ +- (void)pauseSession; + +/** + * Resumes a session which has previously been stopped, or starts a new session if none exists. + * + * If a session has already been resumed or started and has not been stopped, calling this + * method will have no effect. You should disable automatic session tracking via + * autoTrackSessions if you call this method. + * + * It's important to note that sessions are stored in memory for the lifetime of the + * application process and are not persisted on disk. Therefore calling this method on app + * startup would start a new session, rather than continuing any previous session. + * + * You should call this at the appropriate time in your application when you wish to + * resume a previously started session. Any subsequent errors which occur in your application + * will be reported to Bugsnag and will count towards your application's stability score. + * + * @see startSession: + * @see pauseSession: + * + * @return true if a previous session was resumed, false if a new session was started. + */ +- (BOOL)resumeSession; + +// ============================================================================= +// MARK: - onSession +// ============================================================================= + +/** + * Add a callback to be invoked before a session is sent to Bugsnag. + * + * @param block A block which can modify the session + * + * @returns An opaque reference to the callback which can be passed to `removeOnSession:` + */ +- (nonnull BugsnagOnSessionRef)addOnSessionBlock:(nonnull BugsnagOnSessionBlock)block + NS_SWIFT_NAME(addOnSession(block:)); + +/** + * Remove a callback that would be invoked before a session is sent to Bugsnag. + * + * @param callback The opaque reference of the callback, returned by `addOnSessionBlock:` + */ +- (void)removeOnSession:(nonnull BugsnagOnSessionRef)callback + NS_SWIFT_NAME(removeOnSession(_:)); + +/** + * Deprecated + */ +- (void)removeOnSessionBlock:(BugsnagOnSessionBlock _Nonnull )block + BUGSNAG_DEPRECATED_WITH_REPLACEMENT("removeOnSession:") + NS_SWIFT_NAME(removeOnSession(block:)); + +// ============================================================================= +// MARK: - Other methods +// ============================================================================= + +/** + * Retrieves the context - a general summary of what was happening in the application + */ + @property (copy, nullable, atomic) NSString *context; + +/** + * @return YES if Bugsnag has been started and the previous launch crashed + */ +- (BOOL)appDidCrashLastLaunch BUGSNAG_DEPRECATED_WITH_REPLACEMENT("lastRunInfo.crashed"); + +/** + * Information about the last run of the app, and whether it crashed. + */ +@property (readonly, nullable, nonatomic) BugsnagLastRunInfo *lastRunInfo; + +/** + * Tells Bugsnag that your app has finished launching. + * + * Errors reported after calling this method will have the `BugsnagAppWithState.isLaunching` + * property set to false. + */ +- (void)markLaunchCompleted; + +// ============================================================================= +// MARK: - User +// ============================================================================= + +/** + * The current user + */ +- (BugsnagUser *_Nonnull)user; + +/** + * Set user metadata + * + * @param userId ID of the user + * @param name Name of the user + * @param email Email address of the user + */ +- (void)setUser:(NSString *_Nullable)userId + withEmail:(NSString *_Nullable)email + andName:(NSString *_Nullable)name; + +// ============================================================================= +// MARK: - onBreadcrumb +// ============================================================================= + +/** + * Add a callback to be invoked when a breadcrumb is captured by Bugsnag, to + * change the breadcrumb contents as needed + * + * @param block A block which returns YES if the breadcrumb should be captured + * + * @returns An opaque reference to the callback which can be passed to `removeOnBreadcrumb:` + */ +- (nonnull BugsnagOnBreadcrumbRef)addOnBreadcrumbBlock:(nonnull BugsnagOnBreadcrumbBlock)block + NS_SWIFT_NAME(addOnBreadcrumb(block:)); + +/** + * Remove the callback that would be invoked when a breadcrumb is captured. + * + * @param callback The opaque reference of the callback, returned by `addOnBreadcrumbBlock:` + */ +- (void)removeOnBreadcrumb:(nonnull BugsnagOnBreadcrumbRef)callback + NS_SWIFT_NAME(removeOnBreadcrumb(_:)); + +/** + * Deprecated + */ +- (void)removeOnBreadcrumbBlock:(BugsnagOnBreadcrumbBlock _Nonnull)block + BUGSNAG_DEPRECATED_WITH_REPLACEMENT("removeOnBreadcrumb:") + NS_SWIFT_NAME(removeOnBreadcrumb(block:)); + +@end diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagConfiguration.h b/source/ios/Bugsnag.framework/Headers/BugsnagConfiguration.h new file mode 100644 index 0000000..9b5bb38 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagConfiguration.h @@ -0,0 +1,526 @@ +// +// BugsnagConfiguration.h +// +// Created by Conrad Irwin on 2014-10-01. +// +// Copyright (c) 2014 Bugsnag, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall remain in place +// in this source code. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import + +#import +#import +#import +#import +#import +#import +#import +#import + +@class BugsnagUser; +@class BugsnagEndpointConfiguration; +@class BugsnagErrorTypes; + +NS_ASSUME_NONNULL_BEGIN + +/** + * Controls whether Bugsnag should capture and serialize the state of all threads at the time + * of an error. + */ +typedef NS_ENUM(NSInteger, BSGThreadSendPolicy) { + + /** + * Threads should be captured for all events. + */ + BSGThreadSendPolicyAlways = 0, + + /** + * Threads should be captured for unhandled events only. + */ + BSGThreadSendPolicyUnhandledOnly = 1, + + /** + * Threads should never be captured. + */ + BSGThreadSendPolicyNever = 2 +}; + +/** + * Types of telemetry that may be sent to Bugsnag for product improvement purposes. + */ +typedef NS_OPTIONS(NSUInteger, BSGTelemetryOptions) { + + /** + * Errors within the Bugsnag SDK. + */ + BSGTelemetryInternalErrors = (1UL << 0), + + /** + * Information about how Bugsnag has been configured. + */ + BSGTelemetryUsage = (1UL << 1), + + /** + * All types of telemetry are enabled by default. + */ + BSGTelemetryAll = (BSGTelemetryInternalErrors | BSGTelemetryUsage) +}; + +/** + * Setting `BugsnagConfiguration.appHangThresholdMillis` to this value disables the reporting of + * app hangs that ended before the app was terminated. + */ +BUGSNAG_EXTERN const NSUInteger BugsnagAppHangThresholdFatalOnly API_UNAVAILABLE(watchos); + +/** + * A configuration block for modifying an error report + * + * @param event the error report to be modified + */ +typedef BOOL (^BugsnagOnErrorBlock)(BugsnagEvent *_Nonnull event); + +/** + * A handler for modifying data before sending it to Bugsnag. + * + * onSendErrorBlocks will be invoked on a dedicated + * background queue, which will be different from the queue where the block was originally added. + * + * @param event The event report. + * + * @return YES if the event should be sent + */ +typedef BOOL (^BugsnagOnSendErrorBlock)(BugsnagEvent *_Nonnull event); + +/** + * An opaque object that identifies and allows the removal of a BugsnagOnSendErrorBlock. + */ +typedef id BugsnagOnSendErrorRef; + +/** + * A configuration block for modifying a captured breadcrumb + * + * @param breadcrumb The breadcrumb + */ +typedef BOOL (^BugsnagOnBreadcrumbBlock)(BugsnagBreadcrumb *_Nonnull breadcrumb); + +/** + * An opaque object that identifies and allows the removal of a BugsnagOnBreadcrumbBlock. + */ +typedef id BugsnagOnBreadcrumbRef; + +/** + * A configuration block for modifying a session. Intended for internal usage only. + * + * @param session The session about to be delivered + */ +typedef BOOL (^BugsnagOnSessionBlock)(BugsnagSession *_Nonnull session); + +/** + * An opaque object that identifies and allows the removal of a BugsnagOnSessionBlock. + */ +typedef id BugsnagOnSessionRef; + +// ============================================================================= +// MARK: - BugsnagConfiguration +// ============================================================================= + +/** + * Contains user-provided configuration, including API key and endpoints. + */ +BUGSNAG_EXTERN +@interface BugsnagConfiguration : NSObject + +/** + * Create a new configuration from the main bundle's infoDictionary, using keys nested under + * the "bugsnag" key. + * + * @return a BugsnagConfiguration containing the options set in the plist file + */ ++ (instancetype)loadConfig; + +/** + * Initializes a new configuration object with the provided API key. + */ +- (instancetype)initWithApiKey:(nullable NSString *)apiKey NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(_:)); + +/** + * Required declaration to suppress a superclass designated-initializer error + */ +- (instancetype)init NS_UNAVAILABLE NS_SWIFT_UNAVAILABLE("Use initWithApiKey:"); + +// ----------------------------------------------------------------------------- +// MARK: - Properties +// ----------------------------------------------------------------------------- + +/** + * The API key of a Bugsnag project + */ +@property (copy, nonatomic) NSString *apiKey; + +/** + * The release stage of the application, such as production, development, beta + * et cetera + */ +@property (copy, nullable, nonatomic) NSString *releaseStage; + +/** + * Release stages which are allowed to notify Bugsnag + */ +@property (copy, nullable, nonatomic) NSSet *enabledReleaseStages; + +/** + * Sets which values should be removed from any Metadata objects before + * sending them to Bugsnag. Use this if you want to ensure you don't send + * sensitive data such as passwords, and credit card numbers to our + * servers. Any keys which contain a match will be filtered. + * + * By default, redactedKeys is set to ["password"]. Both string literals and regex + * values can be supplied to this property. + */ +@property (copy, nullable, nonatomic) NSSet *redactedKeys; + +/** + * A set of strings and / or NSRegularExpression objects that determine which errors should + * be discarded based on their `errorClass`. + * + * Comparisons are case sensitive. + * + * OnError / OnSendError blocks will not be called for discarded errors. + * + * Some examples of errorClass are: Objective-C exception names like "NSRangeException", + * signal names like "SIGABRT", mach exception names like "EXC_BREAKPOINT", and Swift + * error names like "Fatal error". + */ +@property (copy, nullable, nonatomic) NSSet *discardClasses; + +/** + * A general summary of what was occuring in the application + */ +@property (copy, nullable, atomic) NSString *context; + +/** + * The version of the application + */ +@property (copy, nullable, nonatomic) NSString *appVersion; + +/** + * The URL session used to send requests to Bugsnag. + */ +@property (readwrite, strong, nonnull, nonatomic) NSURLSession *session; + +/** + * Controls whether Bugsnag should capture and serialize the state of all threads at the time + * of an error. + * + * By default sendThreads is set to BSGThreadSendPolicyAlways. This can be set to + * BSGThreadSendPolicyNever to disable or BSGThreadSendPolicyUnhandledOnly + * to only do so for unhandled errors. + */ +@property (nonatomic) BSGThreadSendPolicy sendThreads API_UNAVAILABLE(watchos); + +/** + * Optional handler invoked when an error or crash occurs + */ +@property (nullable, nonatomic) void (* onCrashHandler)(const BSG_KSCrashReportWriter *); + +/** + * YES if uncaught exceptions and other crashes should be reported automatically + */ +@property (nonatomic) BOOL autoDetectErrors; + +/** + * The minimum number of milliseconds of main thread unresponsiveness that will trigger the + * detection and reporting of an app hang. + * + * Set to `BugsnagAppHangThresholdFatalOnly` to disable reporting of app hangs that did not + * end with the app being force quit by the user or terminated by the system watchdog. + * + * By default this is `BugsnagAppHangThresholdFatalOnly`, and can be set to a minimum of 250 + * milliseconds. + */ +@property (nonatomic) NSUInteger appHangThresholdMillis API_UNAVAILABLE(watchos); + +/** + * Whether Bugsnag should report app hangs that occur while the app is in the background. + * + * By default this is false. + */ +@property (nonatomic) BOOL reportBackgroundAppHangs API_UNAVAILABLE(watchos); + +/** + * Determines whether app sessions should be tracked automatically. By default this value is true. + * If this value is updated after +[Bugsnag start] is called, only subsequent automatic sessions + * will be captured. + * + * Note: automatic session tracking is not available in App Extensions. + */ +@property (nonatomic) BOOL autoTrackSessions; + +/** + * The amount of time (in milliseconds) after starting Bugsnag that should be considered part of + * the app's launch. + * + * Events that occur during app launch will have the `BugsnagAppWithState.isLaunching` property + * set to true. + * + * By default this value is 5000 milliseconds. + * + * Setting this to `0` will cause Bugsnag to consider the app to be launching until + * `+[Bugsnag markLaunchCompleted]` or `-[BugsnagClient markLaunchCompleted]` has been called. + */ +@property (nonatomic) NSUInteger launchDurationMillis; + +/** + * Determines whether launch crashes should be sent synchronously during `+[Bugsnag start]`. + * + * If true and the previous run terminated due to a crash during app launch, `+[Bugsnag start]` + * will block the calling thread for up to 2 seconds while the crash report is sent. + * + * By default this value is true. + */ +@property (nonatomic) BOOL sendLaunchCrashesSynchronously; + +/** + * Whether Bugsnag should try to send crashing errors prior to app termination. + * + * Delivery will only be attempted for uncaught Objective-C exceptions and Mach + * exceptions, and while in progress will block the crashing thread for up to 3 + * seconds. + * + * Delivery will be unreliable due to the necessary short timeout and potential + * memory corruption that caused the crashing error in the first place. + * + * If it fails prior to termination, delivery will be reattempted at next launch + * (the default behavior). + * + * Use of this feature is discouraged because it: + * - may cause the app to hang while delivery occurs and impact the hang rate + * reported in Xcode Organizer + * - will result in duplicate crashes in your dashboard for crashes that were + * fully sent but without receiving an HTTP response within the timeout + * - may prevent other crash reporters from detecting the crash. + * + * By default this value is false. + */ +@property (nonatomic) BOOL attemptDeliveryOnCrash; + +/** + * The types of breadcrumbs which will be captured. By default, this is all types. + */ +@property (nonatomic) BSGEnabledBreadcrumbType enabledBreadcrumbTypes; + +/** + * The app's bundleVersion, set from the CFBundleVersion. Equivalent to `versionCode` on Android. + */ +@property (copy, nullable, nonatomic) NSString *bundleVersion; + +@property (copy, nullable, nonatomic) NSString *appType; + +/** + * Sets the maximum number of events which will be stored. Once the threshold is reached, + * the oldest events will be deleted. + * + * By default, 32 events are persisted. + */ +@property (nonatomic) NSUInteger maxPersistedEvents; + +/** + * Sets the maximum number of sessions which will be stored. Once the threshold is reached, + * the oldest sessions will be deleted. + * + * By default, 128 sessions are persisted. + */ +@property (nonatomic) NSUInteger maxPersistedSessions; + +/** + * Sets the maximum number of breadcrumbs which will be stored. Once the threshold is reached, + * the oldest breadcrumbs will be deleted. + * + * By default, 100 breadcrumbs are stored: this can be amended up to a maximum of 500. + */ +@property (nonatomic) NSUInteger maxBreadcrumbs; + +/** + * The maximum length of breadcrumb messages and metadata string values. + * + * Values longer than this will be truncated prior to sending, after running any OnSendError blocks. + * + * The default value is 10000. + */ +@property (nonatomic) NSUInteger maxStringValueLength; + +/** + * Whether User information should be persisted to disk between application runs. + * Defaults to True. + */ +@property (nonatomic) BOOL persistUser; + +/** + * A class defining the types of error that are reported. By default, + * all properties are true. + */ +@property (strong, nonatomic) BugsnagErrorTypes *enabledErrorTypes; + +/** + * Set the endpoints to send data to. By default we'll send error reports to + * https://notify.bugsnag.com, and sessions to https://sessions.bugsnag.com, but you can + * override this if you are using Bugsnag Enterprise to point to your own Bugsnag endpoint. + * + * Please note that it is recommended that you set both endpoints. If the notify endpoint is + * missing, an assertion will be thrown. If the session endpoint is missing, a warning will be + * logged and sessions will not be sent automatically. + */ +@property (copy, nonatomic) BugsnagEndpointConfiguration *endpoints; + +// ============================================================================= +// MARK: - User +// ============================================================================= + +/** + * The current user + */ +@property(readonly, retain, nonnull, nonatomic) BugsnagUser *user; + +/** + * Set user metadata + * + * @param userId ID of the user + * @param name Name of the user + * @param email Email address of the user + * + * If user ID is nil, a Bugsnag-generated Device ID is used for the `user.id` property of events and sessions. + */ +- (void)setUser:(NSString *_Nullable)userId + withEmail:(NSString *_Nullable)email + andName:(NSString *_Nullable)name; + +// ============================================================================= +// MARK: - onSession +// ============================================================================= + +/** + * Add a callback to be invoked before a session is sent to Bugsnag. + * + * @param block A block which can modify the session + * + * @returns An opaque reference to the callback which can be passed to `removeOnSession:` + */ +- (BugsnagOnSessionRef)addOnSessionBlock:(BugsnagOnSessionBlock)block + NS_SWIFT_NAME(addOnSession(block:)); + +/** + * Remove a callback that would be invoked before a session is sent to Bugsnag. + * + * @param callback The opaque reference of the callback, returned by `addOnSessionBlock:` + */ +- (void)removeOnSession:(BugsnagOnSessionRef)callback + NS_SWIFT_NAME(removeOnSession(_:)); + +/** + * Deprecated + */ +- (void)removeOnSessionBlock:(BugsnagOnSessionBlock)block + BUGSNAG_DEPRECATED_WITH_REPLACEMENT("removeOnSession:") + NS_SWIFT_NAME(removeOnSession(block:)); + +// ============================================================================= +// MARK: - onSend +// ============================================================================= + +/** + * Add a callback to be invoked before a report is sent to Bugsnag, to + * change the report contents as needed + * + * @param block A block which returns YES if the report should be sent + * + * @returns An opaque reference to the callback which can be passed to `removeOnSendError:` + */ +- (BugsnagOnSendErrorRef)addOnSendErrorBlock:(BugsnagOnSendErrorBlock)block + NS_SWIFT_NAME(addOnSendError(block:)); + +/** + * Remove the callback that would be invoked before an event is sent. + * + * @param callback The opaque reference of the callback, returned by `addOnSendErrorBlock:` + */ +- (void)removeOnSendError:(BugsnagOnSendErrorRef)callback + NS_SWIFT_NAME(removeOnSendError(_:)); + +/** + * Deprecated + */ +- (void)removeOnSendErrorBlock:(BugsnagOnSendErrorBlock)block + BUGSNAG_DEPRECATED_WITH_REPLACEMENT("removeOnSendError:") + NS_SWIFT_NAME(removeOnSendError(block:)); + +// ============================================================================= +// MARK: - onBreadcrumb +// ============================================================================= + +/** + * Add a callback to be invoked when a breadcrumb is captured by Bugsnag, to + * change the breadcrumb contents as needed + * + * @param block A block which returns YES if the breadcrumb should be captured + * + * @returns An opaque reference to the callback which can be passed to `removeOnBreadcrumb:` + */ +- (BugsnagOnBreadcrumbRef)addOnBreadcrumbBlock:(BugsnagOnBreadcrumbBlock)block + NS_SWIFT_NAME(addOnBreadcrumb(block:)); + +/** + * Remove the callback that would be invoked when a breadcrumb is captured. + * + * @param callback The opaque reference of the callback, returned by `addOnBreadcrumbBlock:` + */ +- (void)removeOnBreadcrumb:(BugsnagOnBreadcrumbRef)callback + NS_SWIFT_NAME(removeOnBreadcrumb(_:)); + +/** + * Deprecated + */ +- (void)removeOnBreadcrumbBlock:(BugsnagOnBreadcrumbBlock)block + BUGSNAG_DEPRECATED_WITH_REPLACEMENT("removeOnBreadcrumb:") + NS_SWIFT_NAME(removeOnBreadcrumb(block:)); + +// ============================================================================= +// MARK: - Telemetry +// ============================================================================= + +/** + * The types of telemetry that may be sent to Bugsnag for product improvement purposes. + * + * By default all types of telemetry are enabled. + */ +@property (nonatomic) BSGTelemetryOptions telemetry; + +// ============================================================================= +// MARK: - Plugins +// ============================================================================= + +/** + * Internal interface for adding custom behavior :nodoc: + */ +- (void)addPlugin:(id _Nonnull)plugin; + +@end + +NS_ASSUME_NONNULL_END diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagDefines.h b/source/ios/Bugsnag.framework/Headers/BugsnagDefines.h new file mode 100644 index 0000000..bb0de02 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagDefines.h @@ -0,0 +1,41 @@ +// +// BugsnagDefines.h +// Bugsnag +// +// Copyright © 2022 Bugsnag Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall remain in place +// in this source code. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#ifndef BugsnagDefines_h +#define BugsnagDefines_h + +#ifndef BUGSNAG_DEPRECATED_WITH_REPLACEMENT +#define BUGSNAG_DEPRECATED_WITH_REPLACEMENT(REPLACEMENT) __attribute__((deprecated ("", REPLACEMENT))) +#endif + +#ifndef BUGSNAG_EXTERN +#ifdef __cplusplus +#define BUGSNAG_EXTERN extern "C" __attribute__((visibility ("default"))) +#else +#define BUGSNAG_EXTERN extern __attribute__((visibility ("default"))) +#endif +#endif + +#endif diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagDevice.h b/source/ios/Bugsnag.framework/Headers/BugsnagDevice.h new file mode 100644 index 0000000..ed1fe5b --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagDevice.h @@ -0,0 +1,71 @@ +// +// BugsnagDevice.h +// Bugsnag +// +// Created by Jamie Lynch on 01/04/2020. +// Copyright © 2020 Bugsnag. All rights reserved. +// + +#import + +#import + +/** + * Stateless information set by the notifier about the device on which the event occurred can be + * found on this class. These values can be accessed and amended if necessary. + */ +BUGSNAG_EXTERN +@interface BugsnagDevice : NSObject + +/** + * Whether the device has been jailbroken + */ +@property (nonatomic) BOOL jailbroken; + +/** + * A unique ID generated by Bugsnag which identifies the device + */ +@property (copy, nullable, nonatomic) NSString *id; + +/** + * The IETF language tag of the locale used + */ +@property (copy, nullable, nonatomic) NSString *locale; + +/** + * The manufacturer of the device used + */ +@property (copy, nullable, nonatomic) NSString *manufacturer; + +/** + * The model ID of the device used, e.g. "iPhone14,1" or "MacBookPro17,1" + */ +@property (copy, nullable, nonatomic) NSString *model; + +/** + * The model number of the device used, e.g. "N841AP" + */ +@property (copy, nullable, nonatomic) NSString *modelNumber; + +/** + * The name of the operating system running on the device used + */ +@property (copy, nullable, nonatomic) NSString *osName; + +/** + * The version of the operating system running on the device used + */ +@property (copy, nullable, nonatomic) NSString *osVersion; + +/** + * A collection of names and their versions of the primary languages, frameworks or + * runtimes that the application is running on + */ +@property (copy, nullable, nonatomic) NSDictionary *runtimeVersions; + +/** + * The total number of bytes of memory on the device + */ +@property (strong, nullable, nonatomic) NSNumber *totalMemory; + +@end diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagDeviceWithState.h b/source/ios/Bugsnag.framework/Headers/BugsnagDeviceWithState.h new file mode 100644 index 0000000..2e92811 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagDeviceWithState.h @@ -0,0 +1,41 @@ +// +// BugsnagDeviceWithState.h +// Bugsnag +// +// Created by Jamie Lynch on 01/04/2020. +// Copyright © 2020 Bugsnag. All rights reserved. +// + +#import + +#import +#import + +/** + * Stateful information set by the notifier about the device on which the event occurred can be + * found on this class. These values can be accessed and amended if necessary. + */ +BUGSNAG_EXTERN +@interface BugsnagDeviceWithState : BugsnagDevice + +/** + * The number of free bytes of storage available on the device + */ +@property (strong, nullable, nonatomic) NSNumber *freeDisk; + +/** + * The number of free bytes of memory available on the device + */ +@property (strong, nullable, nonatomic) NSNumber *freeMemory; + +/** + * The orientation of the device when the event occurred + */ +@property (copy, nullable, nonatomic) NSString *orientation; + +/** + * The timestamp on the device when the event occurred + */ +@property (strong, nullable, nonatomic) NSDate *time; + +@end diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagEndpointConfiguration.h b/source/ios/Bugsnag.framework/Headers/BugsnagEndpointConfiguration.h new file mode 100644 index 0000000..60b85e9 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagEndpointConfiguration.h @@ -0,0 +1,38 @@ +// +// BugsnagEndpointConfiguration.h +// Bugsnag +// +// Created by Jamie Lynch on 15/04/2020. +// Copyright © 2020 Bugsnag. All rights reserved. +// + +#import + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * Set the endpoints to send data to. By default we'll send error reports to + * https://notify.bugsnag.com, and sessions to https://sessions.bugsnag.com, but you can + * override this if you are using Bugsnag Enterprise to point to your own Bugsnag endpoints. + */ +BUGSNAG_EXTERN +@interface BugsnagEndpointConfiguration : NSObject + +/** + * Configures the endpoint to which events should be sent + */ +@property (copy, nonatomic) NSString *notify; + +/** + * Configures the endpoint to which sessions should be sent + */ +@property (copy, nonatomic) NSString *sessions; + +- (instancetype)initWithNotify:(NSString *)notify + sessions:(NSString *)sessions; + +@end + +NS_ASSUME_NONNULL_END diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagError.h b/source/ios/Bugsnag.framework/Headers/BugsnagError.h new file mode 100644 index 0000000..18b0642 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagError.h @@ -0,0 +1,50 @@ +// +// BugsnagError.h +// Bugsnag +// +// Created by Jamie Lynch on 01/04/2020. +// Copyright © 2020 Bugsnag. All rights reserved. +// + +#import + +#import + +@class BugsnagStackframe; + +/** + * Denote which platform or runtime the Error occurred in. + */ +typedef NS_OPTIONS(NSUInteger, BSGErrorType) { + BSGErrorTypeCocoa NS_SWIFT_NAME(cocoa), // Swift won't bring in the zeroeth option by default + BSGErrorTypeC NS_SWIFT_NAME(c), // Fix Swift auto-capitalisation + BSGErrorTypeReactNativeJs +}; + +/** + * An Error represents information extracted from an NSError, NSException, or other error source. + */ +BUGSNAG_EXTERN +@interface BugsnagError : NSObject + +/** + * The class of the error generating the report + */ +@property (copy, nullable, nonatomic) NSString *errorClass; + +/** + * The message of or reason for the error generating the report + */ +@property (copy, nullable, nonatomic) NSString *errorMessage; + +/** + * Sets a representation of this error's stacktrace + */ +@property (copy, nonnull, nonatomic) NSArray *stacktrace; + +/** + * The type of the captured error + */ +@property (nonatomic) BSGErrorType type; + +@end diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagErrorTypes.h b/source/ios/Bugsnag.framework/Headers/BugsnagErrorTypes.h new file mode 100644 index 0000000..d04c99d --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagErrorTypes.h @@ -0,0 +1,77 @@ +// +// BugsnagErrorTypes.h +// Bugsnag +// +// Created by Jamie Lynch on 22/04/2020. +// Copyright © 2020 Bugsnag. All rights reserved. +// + +#import + +#import + +/** + * The types of error that should be reported. + */ +BUGSNAG_EXTERN +@interface BugsnagErrorTypes : NSObject + +/** + * Determines whether App Hang events should be reported to bugsnag. + * + * This flag is true by default. + * + * Note: this flag is ignored in App Extensions, where app hang detection is always disabled. + */ +@property (nonatomic) BOOL appHangs API_UNAVAILABLE(watchos); + +/** + * Determines whether Out of Memory events should be reported to bugsnag. + * + * This flag is true by default. + */ +@property (nonatomic) BOOL ooms API_UNAVAILABLE(watchos); + +/** + * Determines whether Thermal Kill events should be reported to bugsnag. + * + * This flag is true by default. + */ +@property (nonatomic) BOOL thermalKills API_UNAVAILABLE(watchos); + +/** + * Determines whether NSExceptions should be reported to bugsnag. + * + * This flag is true by default. + */ +@property (nonatomic) BOOL unhandledExceptions; + +/** + * Determines whether signals should be reported to bugsnag. + * + * This flag is true by default. + */ +@property (nonatomic) BOOL signals API_UNAVAILABLE(watchos); + +/** + * Determines whether C errors should be reported to bugsnag. + * + * This flag is true by default. + */ +@property (nonatomic) BOOL cppExceptions; + +/** + * Determines whether Mach Exceptions should be reported to bugsnag. + * + * This flag is true by default. + */ +@property (nonatomic) BOOL machExceptions API_UNAVAILABLE(watchos); + +/** + * Sets whether Bugsnag should automatically capture and report unhandled promise rejections. + * This only applies to React Native apps. + * By default, this value is true. + */ +@property (nonatomic) BOOL unhandledRejections; + +@end diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagEvent.h b/source/ios/Bugsnag.framework/Headers/BugsnagEvent.h new file mode 100644 index 0000000..0016271 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagEvent.h @@ -0,0 +1,136 @@ +// +// BugsnagEvent.h +// Bugsnag +// +// Created by Simon Maynard on 11/26/14. +// +// + +#import + +#import +#import +#import + +@class BugsnagConfiguration; +@class BugsnagHandledState; +@class BugsnagSession; +@class BugsnagBreadcrumb; +@class BugsnagAppWithState; +@class BugsnagDeviceWithState; +@class BugsnagMetadata; +@class BugsnagThread; +@class BugsnagError; +@class BugsnagUser; + +/** + * Represents the importance of a particular event. + */ +typedef NS_ENUM(NSUInteger, BSGSeverity) { + BSGSeverityError, + BSGSeverityWarning, + BSGSeverityInfo, +}; + +/** + * Represents an occurrence of an error, along with information about the state of the app and device. + */ +BUGSNAG_EXTERN +@interface BugsnagEvent : NSObject + +// ----------------------------------------------------------------------------- +// MARK: - Properties +// ----------------------------------------------------------------------------- + +/** + * A loose representation of what was happening in the application at the time + * of the event + */ +@property (readwrite, copy, nullable, nonatomic) NSString *context; + +/** + * The severity of the error generating the report + */ +@property (readwrite, nonatomic) BSGSeverity severity; + +/** + * Information extracted from the error that caused the event. The list contains + * at least one error that represents the root cause, with subsequent elements populated + * from the cause. + */ +@property (readwrite, copy, nonnull, nonatomic) NSArray *errors; + +/** + * Customized hash for grouping this report with other errors + */ +@property (readwrite, copy, nullable, nonatomic) NSString *groupingHash; +/** + * Breadcrumbs from user events leading up to the error + */ +@property (readwrite, copy, nonnull, nonatomic) NSArray *breadcrumbs; + +/** + * Feature flags that were active when the error occurred + */ +@property (readonly, strong, nonnull, nonatomic) NSArray *featureFlags; + +/** + * A per-event override for the apiKey. + * - The default value of nil results in the BugsnagConfiguration apiKey being used. + * - Writes are not persisted to BugsnagConfiguration. + */ +@property (readwrite, copy, nullable, nonatomic) NSString *apiKey; + +/** + * Device information such as OS name and version + */ +@property (readonly, nonnull, nonatomic) BugsnagDeviceWithState *device; + +/** + * App information such as the name, version, and bundle ID + */ +@property (readonly, nonnull, nonatomic) BugsnagAppWithState *app; + +/** + * Whether the event was a crash (i.e. unhandled) or handled error in which the system + * continued running. + */ +@property (readwrite, nonatomic) BOOL unhandled; + +/** + * Thread traces for the error that occurred, if collection was enabled. + */ +@property (readwrite, copy, nonnull, nonatomic) NSArray *threads; + +/** + * The original object that caused the error in your application. This value will only be populated for + * non-fatal errors which did not terminate the process, and will contain an NSError or NSException. + * + * Manipulating this field does not affect the error information reported to the + * Bugsnag dashboard. Use event.errors to access and amend the representation of + * the error that will be sent. + */ +@property (strong, nullable, nonatomic) id originalError; + + +// ============================================================================= +// MARK: - User +// ============================================================================= + +/** + * The current user + */ +@property (readonly, nonnull, nonatomic) BugsnagUser *user; + +/** + * Set user metadata + * + * @param userId ID of the user + * @param name Name of the user + * @param email Email address of the user + */ +- (void)setUser:(NSString *_Nullable)userId + withEmail:(NSString *_Nullable)email + andName:(NSString *_Nullable)name; + +@end diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagFeatureFlag.h b/source/ios/Bugsnag.framework/Headers/BugsnagFeatureFlag.h new file mode 100644 index 0000000..4bca644 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagFeatureFlag.h @@ -0,0 +1,28 @@ +// +// BugsnagFeatureFlag.h +// Bugsnag +// +// Created by Nick Dowell on 11/11/2021. +// Copyright © 2021 Bugsnag Inc. All rights reserved. +// + +#import + +#import + +NS_ASSUME_NONNULL_BEGIN + +BUGSNAG_EXTERN +@interface BugsnagFeatureFlag : NSObject + ++ (instancetype)flagWithName:(NSString *)name; + ++ (instancetype)flagWithName:(NSString *)name variant:(nullable NSString *)variant; + +@property (readonly, nonatomic) NSString *name; + +@property (nullable, readonly, nonatomic) NSString *variant; + +@end + +NS_ASSUME_NONNULL_END diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagFeatureFlagStore.h b/source/ios/Bugsnag.framework/Headers/BugsnagFeatureFlagStore.h new file mode 100644 index 0000000..4d526df --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagFeatureFlagStore.h @@ -0,0 +1,31 @@ +// +// BugsnagFeatureFlagStore.h +// Bugsnag +// +// Created by Nick Dowell on 11/11/2021. +// Copyright © 2021 Bugsnag Inc. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol BugsnagFeatureFlagStore + +- (void)addFeatureFlagWithName:(NSString *)name variant:(nullable NSString *)variant +NS_SWIFT_NAME(addFeatureFlag(name:variant:)); + +- (void)addFeatureFlagWithName:(NSString *)name +NS_SWIFT_NAME(addFeatureFlag(name:)); + +- (void)addFeatureFlags:(NSArray *)featureFlags +NS_SWIFT_NAME(addFeatureFlags(_:)); + +- (void)clearFeatureFlagWithName:(NSString *)name +NS_SWIFT_NAME(clearFeatureFlag(name:)); + +- (void)clearFeatureFlags; + +@end + +NS_ASSUME_NONNULL_END diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagLastRunInfo.h b/source/ios/Bugsnag.framework/Headers/BugsnagLastRunInfo.h new file mode 100644 index 0000000..ea2372d --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagLastRunInfo.h @@ -0,0 +1,42 @@ +// +// BugsnagLastRunInfo.h +// Bugsnag +// +// Created by Nick Dowell on 10/02/2021. +// Copyright © 2021 Bugsnag Inc. All rights reserved. +// + +#import + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * Contains information about the last run of the app. + */ +BUGSNAG_EXTERN +@interface BugsnagLastRunInfo : NSObject + +/** + * The number of consecutive runs that have ended with a crash while launching. + * + * See `BugsnagConfiguration.launchDurationMillis` for more information. + */ +@property (readonly, nonatomic) NSUInteger consecutiveLaunchCrashes; + +/** + * True if the previous run crashed. + */ +@property (readonly, nonatomic) BOOL crashed; + +/** + * True if the previous run crashed while launching. + * + * See `BugsnagConfiguration.launchDurationMillis` for more information. + */ +@property (readonly, nonatomic) BOOL crashedDuringLaunch; + +@end + +NS_ASSUME_NONNULL_END diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagMetadata.h b/source/ios/Bugsnag.framework/Headers/BugsnagMetadata.h new file mode 100644 index 0000000..8e18e52 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagMetadata.h @@ -0,0 +1,48 @@ +// +// BugsnagMetaData.h +// +// Created by Conrad Irwin on 2014-10-01. +// +// Copyright (c) 2014 Bugsnag, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall remain in place +// in this source code. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/// :nodoc: +BUGSNAG_EXTERN +@interface BugsnagMetadata : NSObject + +- (instancetype)initWithDictionary:(NSDictionary *)dict; + +/// Configures the metadata object to serialize itself to the provided buffer and file immediately, and upon each change. +- (void)setStorageBuffer:(char *_Nullable *_Nullable)buffer file:(nullable NSString *)file; + +/// Exposed to facilitate unit testing. +- (void)writeData:(NSData *)data toBuffer:(char *_Nullable *_Nonnull)buffer; + +@end + +NS_ASSUME_NONNULL_END diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagMetadataStore.h b/source/ios/Bugsnag.framework/Headers/BugsnagMetadataStore.h new file mode 100644 index 0000000..c68a7d7 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagMetadataStore.h @@ -0,0 +1,223 @@ +// +// BugsnagMetadataStore.h +// Bugsnag +// +// Created by Robin Macharg on 30/03/2020. +// Copyright © 2020 Bugsnag. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** +* Metadata allows semi-arbitrary data to be supplied by the developer. +* It is a set of named sections containing key value pairs, where the +* values can be of any type. +*/ + +// ----------------------------------------------------------------------------- +// MARK: - +// ----------------------------------------------------------------------------- + +/** + * An internal protocol defining methods a Bugsnag metadata store must implement. + */ +@protocol BugsnagMetadataStore + +@required + +/** + * Merge supplied and existing metadata. + * + * - Non-null values will replace existing values for identical keys. + * + * - Null values will remove the existing key/value pair if the key exists. + * Where null-valued keys do not exist they will not be set. (Since ObjC + * dicts can't store 'nil' directly we assume [NSNUll null]) + * + * - Tabs are only created if at least one value is valid. + * + * - Invalid values (i.e. unserializable to JSON) are logged and ignored. + * + * @param metadata A dictionary of string -> id key/value pairs. + * Values should be serializable to JSON. + * + * @param sectionName The name of the metadata section + * + */ +- (void)addMetadata:(NSDictionary *_Nonnull)metadata + toSection:(NSString *_Nonnull)sectionName + NS_SWIFT_NAME(addMetadata(_:section:)); + +/** + * Add a piece of metadata to a particular key in a particular section. + * + * - Non-null values will replace existing values for identical keys. + * + * - Null values will remove the existing key/value pair if the key exists. + * Where null-valued keys do not exist they will not be set. (Since ObjC + * dicts can't store 'nil' directly we assume [NSNUll null]) + * + * - Tabs are only created if at least one value is valid. + * + * - Invalid values (i.e. unserializable to JSON) are logged and ignored. + * + * @param metadata A dictionary of string -> id key/value pairs. + * Values should be serializable to JSON. + * + * @param key The metadata key to store the value under + * + * @param sectionName The name of the metadata section + * + */ +- (void)addMetadata:(id _Nullable)metadata + withKey:(NSString *_Nonnull)key + toSection:(NSString *_Nonnull)sectionName + NS_SWIFT_NAME(addMetadata(_:key:section:)); + +/** + * Get a named metadata section + * + * @param sectionName The name of the section + * @returns The mutable dictionary representing the metadata section, if it + * exists, or nil if not. + */ +- (NSMutableDictionary *_Nullable)getMetadataFromSection:(NSString *_Nonnull)sectionName + NS_SWIFT_NAME(getMetadata(section:)); + +/** + * Get a keyed value from a named metadata section + * + * @param sectionName The name of the section + * @param key The key + * @returns The value if it exists, or nil if not. + */ +- (id _Nullable)getMetadataFromSection:(NSString *_Nonnull)sectionName + withKey:(NSString *_Nonnull)key + NS_SWIFT_NAME(getMetadata(section:key:)); + +/** + * Remove a named metadata section, if it exists. + * + * @param sectionName The section name + */ +- (void)clearMetadataFromSection:(NSString *_Nonnull)sectionName + NS_SWIFT_NAME(clearMetadata(section:)); + +/** + * Remove a specific value for a specific key in a specific metadata section. + * If either section or key do not exist no action is taken. + * + * @param sectionName The section name + * @param key the metadata key + */ +- (void)clearMetadataFromSection:(NSString *_Nonnull)sectionName + withKey:(NSString *_Nonnull)key + NS_SWIFT_NAME(clearMetadata(section:key:)); + +@end + +// ----------------------------------------------------------------------------- +// MARK: - +// ----------------------------------------------------------------------------- + +/** + * A class-level protocol supporting the MetadataStore interface + */ +@protocol BugsnagClassLevelMetadataStore + +@required + +/** + * Merge supplied and existing metadata. + * + * - Non-null values will replace existing values for identical keys. + * + * - Null values will remove the existing key/value pair if the key exists. + * Where null-valued keys do not exist they will not be set. (Since ObjC + * dicts can't store 'nil' directly we assume [NSNUll null]) + * + * - Tabs are only created if at least one value is valid. + * + * - Invalid values (i.e. unserializable to JSON) are logged and ignored. + * + * @param metadata A dictionary of string -> id key/value pairs. + * Values should be serializable to JSON. + * + * @param sectionName The name of the metadata section + * + */ ++ (void)addMetadata:(NSDictionary *_Nonnull)metadata + toSection:(NSString *_Nonnull)sectionName + NS_SWIFT_NAME(addMetadata(_:section:)); + +/** + * Add a piece of metadata to a particular key in a particular section. + * + * - Non-null values will replace existing values for identical keys. + * + * - Null values will remove the existing key/value pair if the key exists. + * Where null-valued keys do not exist they will not be set. (Since ObjC + * dicts can't store 'nil' directly we assume [NSNUll null]) + * + * - Tabs are only created if at least one value is valid. + * + * - Invalid values (i.e. unserializable to JSON) are logged and ignored. + * + * @param metadata A dictionary of string -> id key/value pairs. + * Values should be serializable to JSON. + * + * @param key The metadata key to store the value under + * + * @param sectionName The name of the metadata section + * + */ ++ (void)addMetadata:(id _Nullable)metadata + withKey:(NSString *_Nonnull)key + toSection:(NSString *_Nonnull)sectionName + NS_SWIFT_NAME(addMetadata(_:key:section:)); + +/** + * Get a named metadata section + * + * @param sectionName The name of the section + * @returns The mutable dictionary representing the metadata section, if it + * exists, or nil if not. + */ ++ (NSMutableDictionary *_Nullable)getMetadataFromSection:(NSString *_Nonnull)sectionName + NS_SWIFT_NAME(getMetadata(section:)); + +/** + * Get a keyed value from a named metadata section + * + * @param sectionName The name of the section + * @param key The key + * @returns The value if it exists, or nil if not. + */ ++ (id _Nullable)getMetadataFromSection:(NSString *_Nonnull)sectionName + withKey:(NSString *_Nonnull)key + NS_SWIFT_NAME(getMetadata(section:key:)); + +/** + * Remove a named metadata section, if it exists. + * + * @param sectionName The section name + */ ++ (void)clearMetadataFromSection:(NSString *_Nonnull)sectionName + NS_SWIFT_NAME(clearMetadata(section:)); + +/** + * Remove a specific value for a specific key in a specific metadata section. + * If either section or key do not exist no action is taken. + * + * @param sectionName The section name + * @param key the metadata key + */ ++ (void)clearMetadataFromSection:(NSString *_Nonnull)sectionName + withKey:(NSString *_Nonnull)key + NS_SWIFT_NAME(clearMetadata(section:key:)); + +@end + +NS_ASSUME_NONNULL_END diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagPlugin.h b/source/ios/Bugsnag.framework/Headers/BugsnagPlugin.h new file mode 100644 index 0000000..e67be56 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagPlugin.h @@ -0,0 +1,30 @@ +#ifndef BugsnagPlugin_h +#define BugsnagPlugin_h + +#import + +@class Bugsnag; +@class BugsnagClient; + +/** + * Internal interface for adding custom behavior :nodoc: + */ +@protocol BugsnagPlugin + +@required + +/** + * Loads a plugin with the given Client. When this method is invoked the plugin should + * activate its behaviour - for example, by capturing an additional source of errors. +*/ +- (void)load:(BugsnagClient *_Nonnull)client; + +/** + * Unloads a plugin. When this is invoked the plugin should cease all custom behaviour and + * restore the application to its unloaded state. + */ +- (void)unload; + +@end + +#endif /* BugsnagPlugin_h */ diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagSession.h b/source/ios/Bugsnag.framework/Headers/BugsnagSession.h new file mode 100644 index 0000000..766d5c9 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagSession.h @@ -0,0 +1,52 @@ +// +// BugsnagSession.h +// Bugsnag +// +// Created by Jamie Lynch on 24/11/2017. +// Copyright © 2017 Bugsnag. All rights reserved. +// + +#import + +#import +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * Represents a session of user interaction with your app. + */ +BUGSNAG_EXTERN +@interface BugsnagSession : NSObject + +@property (copy, nonatomic) NSString *id; + +@property (strong, nonatomic) NSDate *startedAt; + +@property (readonly, nonatomic) BugsnagApp *app; + +@property (readonly, nonatomic) BugsnagDevice *device; + +// ============================================================================= +// MARK: - User +// ============================================================================= + +/** + * The current user + */ +@property (readonly, nonnull, nonatomic) BugsnagUser *user; + +/** + * Set user metadata + * + * @param userId ID of the user + * @param name Name of the user + * @param email Email address of the user + */ +- (void)setUser:(nullable NSString *)userId withEmail:(nullable NSString *)email andName:(nullable NSString *)name; + +@end + +NS_ASSUME_NONNULL_END diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagStackframe.h b/source/ios/Bugsnag.framework/Headers/BugsnagStackframe.h new file mode 100644 index 0000000..dff071d --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagStackframe.h @@ -0,0 +1,94 @@ +// +// BugsnagStackframe.h +// Bugsnag +// +// Created by Jamie Lynch on 01/04/2020. +// Copyright © 2020 Bugsnag. All rights reserved. +// + +#import + +#import + +NS_ASSUME_NONNULL_BEGIN + +typedef NSString * BugsnagStackframeType NS_TYPED_ENUM; + +BUGSNAG_EXTERN BugsnagStackframeType const BugsnagStackframeTypeCocoa; + +/** + * Represents a single stackframe from a stacktrace. + */ +BUGSNAG_EXTERN +@interface BugsnagStackframe : NSObject + +/** + * The method name of the stackframe + */ +@property (copy, nullable, nonatomic) NSString *method; + +/** + * The Mach-O file used by the stackframe + */ +@property (copy, nullable, nonatomic) NSString *machoFile; + +/** + * A UUID identifying the Mach-O file used by the stackframe + */ +@property (copy, nullable, nonatomic) NSString *machoUuid; + +/** + * The stack frame address + */ +@property (strong, nullable, nonatomic) NSNumber *frameAddress; + +/** + * The Mach-O file's desired base virtual memory address + */ +@property (strong, nullable, nonatomic) NSNumber *machoVmAddress; + +/** + * The address of the stackframe symbol + */ +@property (strong, nullable, nonatomic) NSNumber *symbolAddress; + +/** + * The address at which the Mach-O file is mapped into memory + */ +@property (strong, nullable, nonatomic) NSNumber *machoLoadAddress; + +/** + * True if `frameAddress` is equal to the value of the program counter register. + */ +@property (nonatomic) BOOL isPc; + +/** + * True if `frameAddress` is equal to the value of the link register. + */ +@property (nonatomic) BOOL isLr; + +/** + * The type of the stack frame, if it differs from that of the containing error or event. + */ +@property (copy, nullable, nonatomic) BugsnagStackframeType type; + +/** + * Creates an array of stackframe objects representing the provided call stack. + * + * @param callStackReturnAddresses An array containing the call stack return addresses, as returned by + * `NSThread.callStackReturnAddresses` or `NSException.callStackReturnAddresses`. + */ ++ (NSArray *)stackframesWithCallStackReturnAddresses:(NSArray *)callStackReturnAddresses; + +/** + * Creates an array of stackframe objects representing the provided call stack. + * + * @param callStackSymbols An array containing the call stack symbols, as returned by `NSThread.callStackSymbols`. + * Each element should be in a format determined by the `backtrace_symbols()` function. + + */ ++ (nullable NSArray *)stackframesWithCallStackSymbols:(NSArray *)callStackSymbols; + +@end + +NS_ASSUME_NONNULL_END diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagThread.h b/source/ios/Bugsnag.framework/Headers/BugsnagThread.h new file mode 100644 index 0000000..14b5cb9 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagThread.h @@ -0,0 +1,57 @@ +// +// BugsnagThread.h +// Bugsnag +// +// Created by Jamie Lynch on 01/04/2020. +// Copyright © 2020 Bugsnag. All rights reserved. +// + +#import + +#import + +typedef NS_OPTIONS(NSUInteger, BSGThreadType) { + BSGThreadTypeCocoa NS_SWIFT_NAME(cocoa) = 0, + BSGThreadTypeReactNativeJs = 1 << 1 +}; + +@class BugsnagStackframe; + +/** + * A representation of thread information recorded as part of a BugsnagEvent. + */ +BUGSNAG_EXTERN +@interface BugsnagThread : NSObject + +/** + * A unique ID which identifies this thread + */ +@property (copy, nullable, nonatomic) NSString *id; + +/** + * The name which identifies this thread + */ +@property (copy, nullable, nonatomic) NSString *name; + +/** + * Whether the error being reported happened in this thread + */ +@property (readonly, nonatomic) BOOL errorReportingThread; + +/** + * The current state of this thread + */ +@property (copy, nullable, nonatomic) NSString *state; + +/** + * Sets a representation of this thread's stacktrace + */ +@property (copy, nonnull, nonatomic) NSArray *stacktrace; + +/** + * Determines the type of thread based on the originating platform + * (intended for internal use only) + */ +@property (nonatomic) BSGThreadType type; + +@end diff --git a/source/ios/Bugsnag.framework/Headers/BugsnagUser.h b/source/ios/Bugsnag.framework/Headers/BugsnagUser.h new file mode 100644 index 0000000..c245611 --- /dev/null +++ b/source/ios/Bugsnag.framework/Headers/BugsnagUser.h @@ -0,0 +1,25 @@ +// +// BugsnagUser.h +// Bugsnag +// +// Created by Jamie Lynch on 24/11/2017. +// Copyright © 2017 Bugsnag. All rights reserved. +// + +#import + +#import + +/** + * Information about the current user of your application. + */ +BUGSNAG_EXTERN +@interface BugsnagUser : NSObject + +@property (readonly, nullable, nonatomic) NSString *id; + +@property (readonly, nullable, nonatomic) NSString *name; + +@property (readonly, nullable, nonatomic) NSString *email; + +@end diff --git a/source/ios/Bugsnag.framework/Info.plist b/source/ios/Bugsnag.framework/Info.plist new file mode 100644 index 0000000..37dc102 Binary files /dev/null and b/source/ios/Bugsnag.framework/Info.plist differ diff --git a/source/ios/Bugsnag.framework/LICENSE b/source/ios/Bugsnag.framework/LICENSE new file mode 100644 index 0000000..a61ef50 --- /dev/null +++ b/source/ios/Bugsnag.framework/LICENSE @@ -0,0 +1,7 @@ +Copyright (c) 2012 Karl Stenerud + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in the documentation of any redistributions of the template files themselves (but not in projects built using the templates). + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/source/ios/Bugsnag.framework/Modules/module.modulemap b/source/ios/Bugsnag.framework/Modules/module.modulemap new file mode 100644 index 0000000..169d387 --- /dev/null +++ b/source/ios/Bugsnag.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module Bugsnag { + umbrella header "Bugsnag.h" + + export * + module * { export * } +} diff --git a/source/ios/Bugsnag.framework/README.md b/source/ios/Bugsnag.framework/README.md new file mode 100644 index 0000000..3de2a65 --- /dev/null +++ b/source/ios/Bugsnag.framework/README.md @@ -0,0 +1,386 @@ +KSCrash +======= + +#### The Ultimate iOS Crash Reporter + + +### Another crash reporter? Why? + +Because while the existing crash reporters do report crashes, there's a heck +of a lot more that they COULD do. Here are some key features of BSG_KSCrash: + +* On-device symbolication in a way that supports re-symbolication offline + (necessary for iOS versions where many functions have been redacted). +* Generates full Apple reports, with every field filled in. +* 32-bit and 64-bit mode. +* Handles errors that can only be caught at the mach level, such as stack + overflow. +* Tracks the REAL cause of an uncaught C++ exception. +* Handles a crash in the crash handler itself (or in the user crash handler + callback). +* Detects zombie (deallocated) object access attempts. +* Recovers lost NSException messages in cases of zombies or memory corruption. +* Introspects objects in registers and on the stack (C strings and Objective-C + objects, including ivars). +* Extracts information about objects referenced by an exception (such as + "unrecognized selector sent to instance 0xa26d9a0") +* Its pluggable server reporting architecture makes it easy to adapt to any API + service. +* Dumps the stack contents. +* Diagnoses crash causes (Crash Doctor). +* Records lots of information beyond what the Apple crash report can, in a JSON + format. +* Supports including extra data that the programmer supplies (before and during + a crash). + +#### BSG_KSCrash handles the following kinds of crashes: + +* Mach kernel exceptions +* Fatal signals +* C++ exceptions +* Objective-C exceptions +* Main thread deadlock (experimental) +* Custom crashes (e.g. from scripting languages) + +#### BSG_KSCrash can report to the following servers: + +* [Hockey](http://hockeyapp.net/) +* [QuincyKit](https://github.com/TheRealKerni/QuincyKit) +* [Victory](https://github.com/kelp404/Victory) +* Email + +[Here are some examples of the reports it can generate.](https://github.com/kstenerud/KSCrash/tree/master/Example-Reports/_README.md) + + +### What's New? + +#### C++ Exception Handling + +That's right! Normally if your app terminates due to an uncaught C++ exception, +all you get is this: + + Thread 0 name: Dispatch queue: com.apple.main-thread + Thread 0 Crashed: + 0 libsystem_kernel.dylib 0x9750ea6a 0x974fa000 + 84586 (__pthread_kill + 10) + 1 libsystem_sim_c.dylib 0x04d56578 0x4d0f000 + 292216 (abort + 137) + 2 libc++abi.dylib 0x04ed6f78 0x4ed4000 + 12152 (abort_message + 102) + 3 libc++abi.dylib 0x04ed4a20 0x4ed4000 + 2592 (_ZL17default_terminatev + 29) + 4 libobjc.A.dylib 0x013110d0 0x130b000 + 24784 (_ZL15_objc_terminatev + 109) + 5 libc++abi.dylib 0x04ed4a60 0x4ed4000 + 2656 (_ZL19safe_handler_callerPFvvE + 8) + 6 libc++abi.dylib 0x04ed4ac8 0x4ed4000 + 2760 (_ZSt9terminatev + 18) + 7 libc++abi.dylib 0x04ed5c48 0x4ed4000 + 7240 (__cxa_rethrow + 77) + 8 libobjc.A.dylib 0x01310fb8 0x130b000 + 24504 (objc_exception_rethrow + 42) + 9 CoreFoundation 0x01f2af98 0x1ef9000 + 204696 (CFRunLoopRunSpecific + 360) + ... + +No way to track what the exception was or where it was thrown from! + +Now with BSG_KSCrash, you get the uncaught exception type, description, and where it was thrown from: + + Application Specific Information: + *** Terminating app due to uncaught exception 'MyException', reason: 'Something bad happened...' + + Thread 0 name: Dispatch queue: com.apple.main-thread + Thread 0 Crashed: + 0 Crash-Tester 0x0000ad80 0x1000 + 40320 (-[Crasher throwUncaughtCPPException] + 0) + 1 Crash-Tester 0x0000842e 0x1000 + 29742 (__32-[AppDelegate(UI) crashCommands]_block_invoke343 + 78) + 2 Crash-Tester 0x00009523 0x1000 + 34083 (-[CommandEntry executeWithViewController:] + 67) + 3 Crash-Tester 0x00009c0a 0x1000 + 35850 (-[CommandTVC tableView:didSelectRowAtIndexPath:] + 154) + 4 UIKit 0x0016f285 0xb4000 + 766597 (-[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1194) + 5 UIKit 0x0016f4ed 0xb4000 + 767213 (-[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 201) + 6 Foundation 0x00b795b3 0xb6e000 + 46515 (__NSFireDelayedPerform + 380) + 7 CoreFoundation 0x01f45376 0x1efa000 + 308086 (__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22) + 8 CoreFoundation 0x01f44e06 0x1efa000 + 306694 (__CFRunLoopDoTimer + 534) + 9 CoreFoundation 0x01f2ca82 0x1efa000 + 207490 (__CFRunLoopRun + 1810) + 10 CoreFoundation 0x01f2bf44 0x1efa000 + 204612 (CFRunLoopRunSpecific + 276) + ... + +#### Handy C++ development helper + +If you turn on trace printing: + +```objective-c +[BSG_KSCrash sharedInstance].printTraceToStdout = YES; +``` + +It will print a proper stack trace to stdout whenever your app throws an +uncaught C++ exception! Otherwise the debugger will only lead you to where the +exception was rethrown. + +#### Custom Crashes & Stack Traces + +You can now report your own custom crashes and stack traces (think scripting +languages): +```objective-c +- (void) reportUserException:(NSString*) name + reason:(NSString*) reason + lineOfCode:(NSString*) lineOfCode + stackTrace:(NSArray*) stackTrace + terminateProgram:(BOOL) terminateProgram; +``` + +See BSG_KSCrash.h for details. + + +### Unstable Features + +The following features should be considered "unstable" and are disabled by default: + +- Deadlock detection + + +### Incompatible API Change Notice + +As of Jan 29th, 2013, I've modified the BSG_KSCrash main API to use properties +rather than init method parameters for configuration. With all the new options, +things were starting to get a bit unwieldly. This should mark the last major +API change. + +Note: The preferred method for initializing BSG_KSCrash is now via the installation + objects rather than using filters directly. See "How to Use BSG_KSCrash" for + details. + + + +How to Build BSG_KSCrash +-------------------- + +1. Select the **KSCrash** scheme. +2. Choose **iOS Device**. +3. Select **Archive** from the **Products** menu. + +When it has finished building, it will show you the framework in Finder. You +can use it like you would any other framework. + + + +How to Use BSG_KSCrash +------------------ + +1. Add the framework to your project (or add the BSG_KSCrash project as a + dependency) + +2. Add the following system frameworks & libraries to your project: + * libc++.dylib + * libz.dylib + * MessageUI.framework (iOS only) + * SystemConfiguration.framework + +3. Add the flag "-ObjC" to **Other Linker Flags** in your **Build Settings** + +4. Add the following to your **[application: didFinishLaunchingWithOptions:]** + method in your app delegate: + + +```objective-c +#import +// Include to use the standard reporter. +#import +// Include to use Quincy or Hockey. +#import +// Include to use the email reporter. +#import +// Include to use Victory. +#import + +- (BOOL)application:(UIApplication*) application didFinishLaunchingWithOptions:(NSDictionary*) launchOptions +{ +KSCrashInstallationStandard* installation = [KSCrashInstallationStandard sharedInstance]; +installation.url = [NSURL URLWithString:@"http://put.your.url.here"]; + +// OR: + +KSCrashInstallationQuincy* installation = [KSCrashInstallationQuincy sharedInstance]; +installation.url = [NSURL URLWithString:@"http://put.your.url.here"]; + +// OR: + +KSCrashInstallationHockey* installation = [KSCrashInstallationHockey sharedInstance]; +installation.appIdentifier = @"PUT_YOUR_HOCKEY_APP_ID_HERE"; + +// OR: + +KSCrashInstallationEmail* installation = [KSCrashInstallationEmail sharedInstance]; +installation.recipients = @[@"some@email.address"]; + +// Optional (Email): Send Apple-style reports instead of JSON +[installation setReportStyle:KSCrashEmailReportStyleApple useDefaultFilenameFormat:YES]; + +// Optional: Add an alert confirmation (recommended for email installation) +[installation addConditionalAlertWithTitle:@"Crash Detected" + message:@"The app crashed last time it was launched. Send a crash report?" + yesAnswer:@"Sure!" + noAnswer:@"No thanks"]; + +// OR: + +KSCrashInstallationVictory* installation = [KSCrashInstallationVictory sharedInstance]; +installation.url = [NSURL URLWithString:@"https://put.your.url.here/api/v1/crash/"]; + +[installation install]; + … +} +``` + +This will install the crash sentry system (which intercepts crashes and stores +reports to disk). Note that there are other properties you can and probably +will want to set for the various installations. + +Once you're ready to send any outstanding crash reports, call the following: + +```objective-c +[installation sendAllReportsWithCompletion:^(NSArray *filteredReports, BOOL completed, NSError *error) +{ + // Stuff to do when report sending is complete +}]; +``` + + +Recommended Reading +------------------- + +If possible, you should read the following header files to fully understand +what features BSG_KSCrash has, and how to use them: + +* BSG_KSCrash.h +* BSG_KSCrashAdvanced.h +* BSG_KSCrashInstallation.h +* BSG_KSCrashInstallation(SPECIFIC TYPE).h +* Architecture.md + + + +Advanced Usage +-------------- + +### Enabling on-device symbolication + +On-device symbolication requires basic symbols to be present in the final +build. To enable this, go to your app's build settings and set **Strip Style** +to **Debugging Symbols**. Doing so increases your final binary size by about +5%, but you get on-device symbolication. + + +### Enabling advanced functionality: + +KSCrash has advanced functionality that can be very useful when examining crash +reports in the wild. Some involve minor trade-offs, so most of them are +disabled by default. + + +#### Custom User Data (userInfo in BSG_KSCrash.h) + +You can store custom user data to the next crash report by setting the +**userInfo** property in BSG_KSCrash.h. + + +#### Zombie Tracking (zombieCacheSize in BSG_KSCrash.h) + +KSCrash has the ability to detect zombie instances (dangling pointers to +deallocated objects). It does this by recording the address and class of any +object that gets deallocated. It stores these values in a cache, keyed off the +deallocated object's address. This means that the smaller you set the cache +size, the greater the chance that a hash collision occurs and you lose +information about a previously deallocated object. + +With zombie tracking enabled, BSG_KSCrash will also detect a lost NSException and +print its contents. Certain kinds of memory corruption or stack corruption +crashes can cause the exception to deallocate early, further twarting efforts +to debug your app, so this feature can be quite handy at times. + +Trade off: Zombie tracking at the cost of adding very slight overhead to object + deallocation, and having some memory reserved. + + +#### Deadlock Detection (deadlockWatchdogInterval in BSG_KSCrash.h) + +**WARNING WARNING WARNING WARNING WARNING WARNING WARNING** + +**This feature is UNSTABLE! It can false-positive and crash your app!** + +If your main thread deadlocks, your user interface will become unresponsive, +and the user will have to manually shut down the app (for which there will be +no crash report). With deadlock detection enabled, a watchdog timer is set up. +If anything holds the main thread for longer than the watchdog timer duration, +KSCrash will shut down the app and give you a stack trace showing what the +main thread was doing at the time. + +This is wonderful, but you must be careful: App initialization generally +occurs on the main thread. If your initialization code takes longer than the +watchdog timer, your app will be forcibly shut down during start up! If you +enable this feature, you MUST ensure that NONE of your normally running code +holds the main thread for longer than the watchdog value! At the same time, +you'll want to set the timer to a low enough value that the user doesn't +become impatient and shut down the app manually before the watchdog triggers! + +Trade off: Deadlock detection, but you must be a lot more careful about what + runs on the main thread! + + +#### Memory Introspection (introspectMemory in BSG_KSCrash.h) + +When an app crashes, there are usually objects and strings in memory that are +being referenced by the stack, registers, or even exception messages. When +enabled, BSG_KSCrash will introspect these memory regions and store their contents +in the crash report. + +You can also specify a list of classes that should not be introspected by +setting the **doNotIntrospectClasses** property in BSG_KSCrash. + + +#### Custom crash handling code (onCrash in BSG_KSCrash.h) + +If you want to do some extra processing after a crash occurs (perhaps to add +more contextual data to the report), you can do so. + +However, you must ensure that you only use async-safe code, and above all else +never call Objective-C code from that method! There are many cases where you +can get away with doing so anyway, but there are certain classes of crashes +where handler code that disregards this warning will cause the crash handler +to crash! Note that if this happens, BSG_KSCrash will detect it and write a full +report anyway, though your custom handler code may not fully run. + +Trade off: Custom crash handling code, but you must be careful what you put + in it! + + +#### BSG_KSCrash log redirection (BSG_KSCrashAdvanced.h) + +This takes whatever BSG_KSCrash would have printed to the console, and writes it +to a file instead. I mostly use this for debugging BSG_KSCrash itself, but it could +be useful for other purposes, so I've exposed an API for it. + + + +Examples +-------- + +The workspace includes some example apps, which demonstrate common BSG_KSCrash +usage. Please look at the top of AppDelegate.m in each app for a description +of what it does. + + + +License +------- + +Copyright (c) 2012 Karl Stenerud + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +the documentation of any redistributions of the template files themselves +(but not in projects built using the templates). + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/source/ios/Plugin/PluginBugsnag.mm b/source/ios/Plugin/PluginBugsnag.mm index 34e7803..4001fbf 100644 --- a/source/ios/Plugin/PluginBugsnag.mm +++ b/source/ios/Plugin/PluginBugsnag.mm @@ -40,6 +40,8 @@ static int crash( lua_State *L ); private: CoronaLuaRef fListener; + static bool isDebug; + }; // ---------------------------------------------------------------------------- @@ -49,6 +51,7 @@ // This corresponds to the event name, e.g. [Lua] event.name const char PluginBugsnag::kEvent[] = "pluginbugsnagevent"; +bool PluginBugsnag::isDebug = NO; PluginBugsnag::PluginBugsnag() : fListener( NULL ) @@ -122,8 +125,10 @@ if ( lua_type( L, 1 ) == LUA_TSTRING ) { const char *breadcrumb = lua_tostring( L, 1 ); + if (isDebug == true) { + NSLog(@"**** Bugsnag Plugin will leave breadcrumb %s .", breadcrumb); + } - NSLog(@"**** Bugsnag Plugin will leave breadcrumb %s .", breadcrumb); [Bugsnag leaveBreadcrumbWithMessage:[NSString stringWithUTF8String:breadcrumb]]; } @@ -135,6 +140,7 @@ { NSLog(@"**** Bugsnag Plugin will report error. ONLY CALL bugsnag.crash() DURING TESTING"); [Bugsnag notifyError:[NSError errorWithDomain:@"errortest.com" code:408 userInfo:nil]]; + return 0; } @@ -143,10 +149,11 @@ PluginBugsnag::init( lua_State *L ) { int listenerIndex = 1; - int tableIndex = 2; const char* userId = NULL; const char* email = NULL; const char* name = NULL; + isDebug = NO; + if ( CoronaLuaIsListener( L, listenerIndex, kEvent ) ) @@ -157,9 +164,9 @@ library->Initialize( listener ); } - if ( lua_type( L, 2 ) == LUA_TTABLE ) + if ( lua_type( L, -1 ) == LUA_TTABLE ) { - lua_getfield( L, 2, "id" ); + lua_getfield( L, -1, "id" ); if ( lua_type( L, -1 ) == LUA_TSTRING ) { userId = lua_tostring( L, -1 ); @@ -167,7 +174,7 @@ lua_pop( L, 1 ); - lua_getfield( L, 2, "email" ); + lua_getfield( L, -1, "email" ); if ( lua_type( L, -1 ) == LUA_TSTRING ) { email = lua_tostring( L, -1 ); @@ -176,25 +183,42 @@ lua_pop( L, 1 ); - lua_getfield( L, 2, "name" ); + lua_getfield( L, -1, "name" ); if ( lua_type( L, -1 ) == LUA_TSTRING ) { name = lua_tostring( L, -1 ); } lua_pop( L, 1 ); + + lua_getfield( L, -1, "isDebug" ); + if ( lua_type( L, -1 ) == LUA_TBOOLEAN ) + { + isDebug = lua_toboolean(L, -1); + } + + lua_pop( L, 1 ); } - - NSLog(@"**** Bugsnag Plugin Will Start"); + if (isDebug == YES) { + NSLog(@"**** Bugsnag Plugin Will Start"); + } try { BugsnagConfiguration *config = [BugsnagConfiguration loadConfig]; if (userId != NULL && email != NULL && name != NULL) { + if (isDebug == YES) { + NSLog(@"**** Bugsnag start with email: %s, userId: %s, and name: %s.", email, userId, name); + } + [config setUser:[NSString stringWithUTF8String:userId] withEmail:[NSString stringWithUTF8String:email] andName:[NSString stringWithUTF8String:name]]; [Bugsnag startWithConfiguration:config]; }else { + if (isDebug == YES) { + NSLog(@"**** Bugsnag start"); + } + [Bugsnag start]; } diff --git a/source/ios/bugsnag.xcodeproj/xcshareddata/xcschemes/plugin_bugsnag.xcscheme b/source/ios/bugsnag.xcodeproj/xcshareddata/xcschemes/plugin_bugsnag.xcscheme new file mode 100644 index 0000000..0e2e651 --- /dev/null +++ b/source/ios/bugsnag.xcodeproj/xcshareddata/xcschemes/plugin_bugsnag.xcscheme @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + +