![](/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.