diff --git a/.gitignore b/.gitignore index 7c38f3a..a40999a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ xcuserdata xcframeworks Vendor archives +Tools/symbol-upload-macos diff --git a/BugSplat.h b/BugSplat.h index e8cb545..6dbe369 100644 --- a/BugSplat.h +++ b/BugSplat.h @@ -75,8 +75,25 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, copy, nullable) NSString *userID; -/** Set the bugsplat database name, which will override the "BugSplatDatabase" Info.plist key value */ -@property (nonatomic, assign) NSString *bugSplatDatabase; +/** + * The database name BugSplat will use to construct the BugSplatDatabase URL where crash reports will be submitted. + * + * NOTES: + * By default, the BugSplat database name is pulled from the App's Info.plist. + * + * When a third party library or plugin developer is leveraging BugSplat, but the App developer incorporating + * the plugin is not using BugSplat, programmatically setting this property would be appropriate. + * + * Only one BugSplat database can be specified within an App including any third party libraries and plugins. + * This means if the Info.plist contains a BugSplat database, attempting to change this property will have no effect. + * + * Additionally, if the Info.plist does not contain a BugSplat database key and value, the first call to + * set this property will set the BugSplat database name. Any subsequent calls to set this property will have no effect. + * + * Finally, with the above considerations, if programmatic change of this property is desired, it must be set before calling + * BugSplat `start` method or it will have no effect. + */ +@property (nonatomic, copy, nullable) NSString *bugSplatDatabase; /** Set the user name that should used in the SDK components diff --git a/BugSplat.m b/BugSplat.m index 4fc2c76..082f6c6 100644 --- a/BugSplat.m +++ b/BugSplat.m @@ -12,6 +12,9 @@ @interface BugSplat() +/** set to YES if start is called and returns successfully */ +@property (atomic, assign) BOOL isStartInvoked; + /** * Attributes represent app supplied keys and values additional to the crash report. * Attributes will be bundled up in a BugSplatAttachment as NSData, with a filename of CrashContext.xml, MIME type of "application/xml" and encoding of "UTF-8". @@ -28,6 +31,10 @@ @interface BugSplat() @implementation BugSplat + // internal instance variable + NSString * _bugSplatDatabase = nil; + + + (instancetype)shared { static BugSplat *sharedInstance = nil; @@ -45,6 +52,8 @@ - (instancetype)init if (self = [super init]) { [[BITHockeyManager sharedHockeyManager] configureWithIdentifier:kHockeyIdentifierPlaceholder]; + self.isStartInvoked = NO; + #if TARGET_OS_OSX _autoSubmitCrashReport = NO; _askUserDetails = YES; @@ -56,22 +65,6 @@ - (instancetype)init self.bannerImage = bannerImage; } #endif - - id bugSplatDatabaseValue = [self.bundle objectForInfoDictionaryKey:kBugSplatDatabase]; - if (bugSplatDatabaseValue == nil) { - NSLog(@"*** BugSplat init: BugSplatDatabase is missing from your Info.plist - Please add this key/value to the your app's Info.plist or use setBugSplatDatabase to set it from code ***"); - - // NSAssert is set to be ignored in this library in Release builds - NSAssert(NO, @"BugSplat init: BugSplatDatabase is missing from your Info.plist - Please add this key/value to the your app's Info.plist or use setBugSplatDatabase to set it from code"); - } else { - NSString *bugSplatDatabase = (NSString *)bugSplatDatabaseValue; - NSLog(@"BugSplat init: BugSplat BugSplatDatabase set as [%@]", bugSplatDatabase); - - NSString *serverURL = [NSString stringWithFormat: @"https://%@.bugsplat.com/", bugSplatDatabase]; - - NSLog(@"BugSplat init: setServerURL: [%@]", serverURL); - [[BITHockeyManager sharedHockeyManager] setServerURL:serverURL]; - } } return self; @@ -80,13 +73,33 @@ - (instancetype)init - (void)start { NSLog(@"BugSplat start..."); - + + if (!self.bugSplatDatabase) + { + NSLog(@"*** BugSplatDatabase is nil. Please add this key/value to the your app's Info.plist or set bugSplatDatabase before invoking start. ***"); + + // NSAssert is set to be ignored in this library in Release builds + NSAssert(NO, @"*** BugSplatDatabase is nil. Please add this key/value to the your app's Info.plist or set bugSplatDatabase before invoking start. ***"); + self.isStartInvoked = NO; // unsuccessful return + return; + } + + if (self.isStartInvoked) + { + NSLog(@"*** BugSplat `start` was already invoked. ***"); + return; + } + + NSLog(@"BugSplat BugSplatDatabase set as [%@]", self.bugSplatDatabase); + NSString *serverURL = [NSString stringWithFormat: @"https://%@.bugsplat.com/", self.bugSplatDatabase]; // Uncomment line below to enable HockeySDK logging // [[BITHockeyManager sharedHockeyManager] setLogLevel:BITLogLevelVerbose]; - // setServerUrl will be called from either `init` or `setBugSplatDatabase` + NSLog(@"BugSplat setServerURL: [%@]", serverURL); + [[BITHockeyManager sharedHockeyManager] setServerURL:serverURL]; [[BITHockeyManager sharedHockeyManager] startManager]; + self.isStartInvoked = YES; } - (void)setDelegate:(id)delegate @@ -104,12 +117,31 @@ - (NSBundle *)bundle return [NSBundle mainBundle]; // return app's main bundle, not BugSplat framework's bundle } +- (NSString *)bugSplatDatabase +{ + // defer to Info.plist value if present + NSString *bugSplatDatabaseValue = (NSString *)[self.bundle objectForInfoDictionaryKey:kBugSplatDatabase]; + if (bugSplatDatabaseValue) + { + return [bugSplatDatabaseValue copy]; + } + + return _bugSplatDatabase; +} + - (void)setBugSplatDatabase:(NSString *)bugSplatDatabase { - NSString *serverURL = [NSString stringWithFormat: @"https://%@.bugsplat.com/", bugSplatDatabase]; + // if a value is already present, do not change it + if (self.bugSplatDatabase) + { + return; + } - NSLog(@"BugSplat setBugSplatDatabase: setServerURL: [%@]", serverURL); - [[BITHockeyManager sharedHockeyManager] setServerURL:serverURL]; + // Set a value if value is not nil, and if isStartInvoked is NO + if (bugSplatDatabase && !self.isStartInvoked) + { + _bugSplatDatabase = [bugSplatDatabase copy]; + } } - (void)setUserID:(NSString *)userID diff --git a/Tools/symbol-upload-macos b/Tools/symbol-upload-macos deleted file mode 100755 index cf0c50a..0000000 --- a/Tools/symbol-upload-macos +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1c543ba2ce3ff93d82c9a88321e95e4c75be1bd5c9855df7684be5209cb48126 -size 125565600