简体   繁体   English

创建addPersistentStoreWithType方法使用的选项Dictionary时,应用程序崩溃

[英]Application is crashing when creating a options Dictionary used by addPersistentStoreWithType method

I am using encrypted-core-data to encrypts all data that is persisted , previously simple CoreData was using. 我使用encrypted-core-data来加密所有持久存储的数据,以前是CoreData正在使用的简单数据。 persistentStoreCoordinator creation code are as follows . persistentStoreCoordinator创建代码如下。

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (_persistentStoreCoordinator != nil) {
    return _persistentStoreCoordinator;
}

NSURL *oldStoreURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"VistaJetApp.sqlite"];
NSURL *newStoreURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"VistaJet.sqlite"];
NSError *error = nil;

NSString *currentPassword = [[VJAesCryptoWrapper getInstance] getCurrentPassword];
NSDictionary *options = [self getEncryptedStoreOptionsWithPassword:currentPassword andDatabaseStore:newStoreURL];

_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];

//if old store not exists , it means fresh installation
if([[NSFileManager defaultManager] fileExistsAtPath:oldStoreURL.path] == NO) {             
    if (![_persistentStoreCoordinator addPersistentStoreWithType:EncryptedStoreType configuration:nil URL:newStoreURL options:options error: &error]) {         
    }        
} else {

    if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:oldStoreURL options:@{NSMigratePersistentStoresAutomaticallyOption:@YES, NSInferMappingModelAutomaticallyOption:@YES} error: &error]) {                     
    }

    NSPersistentStore *oldUnsecureStore = [_persistentStoreCoordinator persistentStoreForURL:oldStoreURL];
    [ConsoleLogger logText:[NSString stringWithFormat:@"Migration started"]];

    //start migration
    if(![_persistentStoreCoordinator migratePersistentStore:oldUnsecureStore toURL:newStoreURL options:options withType:EncryptedStoreType error:&error]) {


    } else {
        [[NSFileManager defaultManager] removeItemAtURL:oldStoreURL error:nil];
    }

}

return _persistentStoreCoordinator;

}

Creation of options dictionary 创建选项字典

- (NSDictionary*)getEncryptedStoreOptionsWithPassword:(NSString*)password andDatabaseStore:(NSURL*)storeUrl {
return @{ EncryptedStorePassphraseKey: password,
          EncryptedStoreDatabaseLocation: storeUrl,
          NSMigratePersistentStoresAutomaticallyOption:@YES,
          NSInferMappingModelAutomaticallyOption:@YES
          };
}

I am saving password in keychain using KeychainItemWrapper and my code crashing exactly on getEncryptedStoreOptionsWithPassword:currentPassword method. 我使用KeychainItemWrapper在密钥链中保存密码,我的代码完全崩溃在getEncryptedStoreOptionsWithPassword:currentPassword方法上。 App is live and I am not able to reproduce the crash , but on crashlytics it is showing so many crashes 应用程序是实时的,我无法重现崩溃,但在崩溃问题上,它显示出如此多的崩溃

crashlytics crash logs image crashlytics崩溃日志图像

Also using AESCrypt to encrypt password then saving it to keychain using KeychainItemWrapper . 还使用AESCrypt加密密码,然后使用KeychainItemWrapper将其保存到钥匙KeychainItemWrapper

Observation: 观察:
The crash that crashlytics is displaying only appear when we upload build on test flight using distribution profile. 只有当我们使用分发配置文件在测试航班上上传构建时,才会显示崩溃关系所显示的崩溃。

crash is happening 100% on iOS 11 as reported by crashlytics 据崩溃论者报道,iOS 11上发生了100%的崩溃事件

I think this is a known bug in iOS 10 that you are seeing, there is a work-around: enable "Keychain Sharing" (under your app -> Capabilities tab in Xcode). 我认为这是你所看到的iOS 10中的一个已知错误,有一个解决方法:启用“Keychain Sharing”(在你的应用程序 - Xcode中的Capabilities选项卡下)。

KeychainItemWrapper crash on iOS10 KeychainItemWrapper在iOS10上崩溃

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iPhone 没有崩溃,仪器没有泄漏,应用程序准备好上传了吗? - iPhone not crashing, no leaks in instruments, is the application ready for upload? 尝试验证档案时Xcode 5崩溃 - Xcode 5 crashing when trying to validate archives 为iPhone创建应用程序URL - Creating Application URL for iPhone 单击主页按钮时应用程序崩溃 - App is crashing when home button clicked 如果使用IAP,为什么需要使用Application Loader上载应用程序? - Why does Application Loader need to be used to upload an app if it uses IAP? 如何知道何时在Android中完成应用程序下载? - How to know when application download completes in android? 上载应用程序更新时无法选择构建 - Cannot choose build when uploading an update for application 将代码库从Titan更改为Swift后,从应用程序商店更新应用程序时,应用程序崩溃 - App crashing when updating app from app store after codebase changed from titanium to Swift 从App Store下载Xcode时,我必须使用我的开发者帐户吗? - Must I used my developer account when downloading Xcode from the App Store? ios为不同客户针对同一应用程序的不同版本/自定义的发布/推出选项? - ios publish / rollout options for different versions / customizations of the same application to different customers?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM