![](/img/trans.png)
[英]iPhone not crashing, no leaks in instruments, is the application ready for upload?
[英]Application is crashing when creating a options Dictionary used by addPersistentStoreWithType method
我使用encrypted-core-data
来加密所有持久存储的数据,以前是CoreData
正在使用的简单数据。 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;
}
创建选项字典
- (NSDictionary*)getEncryptedStoreOptionsWithPassword:(NSString*)password andDatabaseStore:(NSURL*)storeUrl {
return @{ EncryptedStorePassphraseKey: password,
EncryptedStoreDatabaseLocation: storeUrl,
NSMigratePersistentStoresAutomaticallyOption:@YES,
NSInferMappingModelAutomaticallyOption:@YES
};
}
我使用KeychainItemWrapper
在密钥链中保存密码,我的代码完全崩溃在getEncryptedStoreOptionsWithPassword:currentPassword
方法上。 应用程序是实时的,我无法重现崩溃,但在崩溃问题上,它显示出如此多的崩溃
还使用AESCrypt
加密密码,然后使用KeychainItemWrapper
将其保存到钥匙KeychainItemWrapper
。
观察:
只有当我们使用分发配置文件在测试航班上上传构建时,才会显示崩溃关系所显示的崩溃。
据崩溃论者报道,iOS 11上发生了100%的崩溃事件
我认为这是你所看到的iOS 10中的一个已知错误,有一个解决方法:启用“Keychain Sharing”(在你的应用程序 - Xcode中的Capabilities选项卡下)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.