我有一个非常令人沮丧的错误。我已经通过首先安装以前的版本 (1.0.1) 然后运行版本 (1.0.2) 来测试应用程序升级。一切正常。我提交了应用程序,然后我遇到了人们在升级时遇到崩溃的问题。我尝试做同样的事情,安装 1.0.1,然后在应用商店安装二进制文件,然后它崩溃了。我查看了控制台和崩溃日志,我得到了这个:
Jul 7 08:07:45 unknown MyApp[1429] <Warning>: KeychainUtils keychainValueForKey: - Error finding keychain value for key. Status code = -25300
Jul 7 08:07:45 unknown MyApp[1429] <Warning>: AccountSession readUserDataFromDisk - Error finding keychain value for key /var/mobile/Applications/997B32E7-6FFC-4696-9CAA-129BADE2FE64/Documents/instagram_json
Jul 7 08:07:45 unknown MyApp[1429] <Warning>: UISegmentedControlStyleBezeled is deprecated. Please use a different style.
Jul 7 08:07:45 unknown MyApp[1429] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: username)'
*** First throw call stack:
(0x33ee688f 0x367e7259 0x33ee6789 0x33ee67ab 0x33e5368b 0x14fd99 0x152319 0x1530bb 0x170299 0x3270ec59 0x32711817 0x354e7dfb 0x354e7cd0)
Jul 7 08:07:45 unknown UIKitApplication:com.firesnakelabs.pinstagram[0x14e4][1429] <Notice>: terminate called throwing an exception
>
更新:
我想我知道问题是什么,升级它正在寻找的文件路径是:
/var/mobile/Applications/997B32E7-6FFC-4696-9CAA-129BADE2FE64/Documents/instagram_json
而在升级(v1.0.1)之前,钥匙串的文件路径位于:
/var/mobile/Applications/CEE344F7-4FE1-4455-BD6D-A4D6EAA4F5FE/Documents/instagram_json
因此它现在找不到钥匙串上的钥匙,这是我确定文件路径的方法:
- (NSString *)filePath {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_json", self.identifier]];
return filePath;
}
我只是走我找到的第一条路。那么如何使路径在升级前后或一直保持一致?
我基本上使用 filePath 作为钥匙串名称:
[attributesDictionary setObject:filePath forKey:(id)kSecAttrAccount]; // Use the key as the account name