diff --git a/Sources/KSCrashRecording/KSCrash.m b/Sources/KSCrashRecording/KSCrash.m index e2110142d..1d541f949 100644 --- a/Sources/KSCrashRecording/KSCrash.m +++ b/Sources/KSCrashRecording/KSCrash.m @@ -62,6 +62,7 @@ @interface KSCrash () @end static NSString *gCustomBasePath = nil; +static BOOL gIsSharedInstanceCreated = NO; static NSString* getBundleName(void) { @@ -129,6 +130,14 @@ + (void)initialize + (void) setBasePath:(NSString*) basePath; { + if(basePath == gCustomBasePath || [basePath isEqualToString:gCustomBasePath]) + { + return; + } + if(gIsSharedInstanceCreated) + { + KSLOG_WARN(@"A shared instance of KSCrash is already created. Can't change the base path to: %@", basePath); + } gCustomBasePath = [basePath copy]; } @@ -139,6 +148,7 @@ + (instancetype) sharedInstance dispatch_once(&onceToken, ^{ sharedInstance = [[KSCrash alloc] initWithBasePath:getBasePath()]; + gIsSharedInstanceCreated = YES; }); return sharedInstance; }