当我从 XCode 运行我的应用程序时,它不会崩溃,但我创建了一个 IPA 以与 TestFlight 一起使用,并且在用户尝试登录应用程序后它会崩溃。我相信这是由于使用了此处定义的 keychainItemWrapper 库:https ://gist.github.com/dhoerl/1170641
这是我的崩溃报告的样子:
Incident Identifier: 906A698B-555F-4922-8596-27FE481E9522
CrashReporter Key: 8722e51d4300c003d1ac939808b1a9c67f112194
Hardware Model: iPhone6,1
Process: -
Path: /var/mobile/Applications/B2EFB5F3-86C0-4E87-850D-27F771A1FA41/App.app/App
Identifier: -
Version: 1.0 (1.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2014-09-08 21:10:03.911 -0400
OS Version: iOS 7.1.2 (11D257)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x000000008945bec8
Triggered by Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x00000001991ac0b8 objc_retain + 24
1 App 0x000000010008118c -[LoginViewController loginClick:] (LoginViewController.m:246)
...
在 LoginViewController 的第 246 行,我运行以下方法:
[self authenticateUser];
定义如下:
-(IBAction)authenticateUser {
[keychainItem resetKeychainItem]; // remove any existing auth_token
[keychainItem setObject:[_txtUsername text] forKey:(__bridge id)(kSecAttrAccount)];
NSURL *url=[NSURL URLWithString:sessionsBaseURL];
NSError *error = [[NSError alloc] init];
NSDictionary * userDict = [[NSDictionary alloc] initWithObjectsAndKeys: [_txtUsername text], @"username", [_txtPassword text], @"password", nil];
NSDictionary * holderDict = [[NSDictionary alloc] initWithObjectsAndKeys: userDict, @"user", nil];
NSLog(@"user holderDict: %@", holderDict);
NSData * holder = [NSJSONSerialization dataWithJSONObject:holderDict options:0 error:&error];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:holder];
NSURLResponse * response = nil;
NSData * receivedData = nil;
receivedData = [NSMutableData data];
receivedData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
// get dictionary from json data
NSDictionary * jsonResponse = [NSJSONSerialization
JSONObjectWithData: receivedData
options:kNilOptions
error:&error];
NSLog(@"jsonResponse: %@", jsonResponse);
NSDictionary * dataResponse = [jsonResponse objectForKey:@"data"];
auth_token = [dataResponse objectForKey:@"auth_token"];
// save user authentication token in NSUserDefaults
NSUserDefaults* preferences = [NSUserDefaults standardUserDefaults];
[keychainItem setObject:[dataResponse objectForKey:@"auth_token"] forKey:(__bridge id)(kSecValueData)];
[self checkLoginApproved];
}
我非常感谢任何帮助,因为它阻止我发布我的应用程序!