[英]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.