+ Start a Discussion
Kyle Roberts 1Kyle Roberts 1 

iOS SmartStore invalid after switching users - Error code 999

Logging in with Salesforce, logging out, and logging in as a different user passes errors when trying to query the Smartstore.

 

Error referring to the Smartstore SQL database in the file system:
Domain=com.salesforce.smartstore.error Code=999 "file is encrypted or is not a database" UserInfo=0x7b145db0 {NSLocalizedDescription=file is encrypted or is not a database}

Example simple query and store getter where it crashes:
NSArray *results = [self.store queryWithQuerySpec:query pageIndex:0 error:&error];
- (SFSmartStore *)store {
   if (_store == nil) {
      _store = [SFSmartStore sharedStoreWithName:kDefaultSmartStoreName];
      if (![_store soupExists:self.objectClassName]) {
         [_store registerSoup:self.objectClassName withIndexSpecs:self.indexSpecs];
         NSAssert([_store soupExists:self.objectClassName], @"Unable to register soup: %@", self.objectClassName);
      }
    }
   return _store;
}

Though the app does not always crash, it will hits exception breakpoints but can continue past them and this issue causes other problems and crashing down the road during sync and the rest of the app's session.

I have read that on logout, the SDK is supposed to clear the current user's Smartstore but there are still some directories and SQLite files left in the documents directory. We have tried manually removing the files, removing the entire contents of the documents directory, simply clearing the soups. Anyone have any experience with this issue or 999 error codes?

Michael CaulleyMichael Caulley
Did you ever solve your issue?