我最近通過iTunes Connect將我的應用程序提交給Apple,現在它已經在iTunes商店中。但是,當我將它下載到朋友的iPhone上時,它立即崩潰。我在iPhone模擬器和iPad上測試了它(我沒有iPhone)。所以,我插在iPhone進入我的電腦,並得到了它這個崩潰日誌:iPhone上的奇怪應用程序崩潰 - 未被Apple拒絕
Incident Identifier: 893F48B6-9805-4BF7-BA84-D5CDF85392E8
CrashReporter Key: 72f4227f4240642bb75dcb75873b6f4b42cf3cf7
Hardware Model: iPhone3,1
Process: App [305]
Path: /var/mobile/Applications/4A493313-CB6D-422D-8098-BB2DE94A30B2/-----.app/-----
Identifier: App
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2012-03-10 13:40:30.841 -0700
OS Version: iPhone OS 5.0.1 (9A405)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x35d7732c 0x35d66000 + 70444
1 libsystem_c.dylib 0x32c40f54 0x32bf3000 + 319316
2 libsystem_c.dylib 0x32c39fe4 0x32bf3000 + 290788
3 GraphicsServices 0x30637444 0x30633000 + 17476
4 GraphicsServices 0x30637e84 0x30633000 + 20100
5 UIKit 0x37233520 0x37202000 + 202016
6 App 0x000104d0 main (main.m:14)
7 App 0x00010488 start + 32
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x35d673b4 0x35d66000 + 5044
1 libdispatch.dylib 0x36a91e78 0x36a85000 + 52856
2 libdispatch.dylib 0x36a91b96 0x36a85000 + 52118
Thread 2:
0 libsystem_kernel.dylib 0x35d77cd4 0x35d66000 + 72916
1 libsystem_c.dylib 0x32bfd30a 0x32bf3000 + 41738
2 libsystem_c.dylib 0x32bfd09c 0x32bf3000 + 41116
Thread 3:
0 libsystem_kernel.dylib 0x35d77cd4 0x35d66000 + 72916
1 libsystem_c.dylib 0x32bfd30a 0x32bf3000 + 41738
2 libsystem_c.dylib 0x32bfd09c 0x32bf3000 + 41116
Thread 4 name: WebThread
Thread 4:
0 libsystem_kernel.dylib 0x35d67010 0x35d66000 + 4112
1 libsystem_kernel.dylib 0x35d67206 0x35d66000 + 4614
2 CoreFoundation 0x33e3041c 0x33da3000 + 578588
3 CoreFoundation 0x33e2f154 0x33da3000 + 573780
4 CoreFoundation 0x33db24d6 0x33da3000 + 62678
5 CoreFoundation 0x33db239e 0x33da3000 + 62366
6 WebCore 0x36286128 0x361de000 + 688424
7 libsystem_c.dylib 0x32c02c16 0x32bf3000 + 64534
8 libsystem_c.dylib 0x32c02ad0 0x32bf3000 + 64208
Thread 0 crashed with ARM Thread State:
r0: 0x00000000 r1: 0x00000000 r2: 0x00000001 r3: 0x00000000
r4: 0x00000006 r5: 0x3e52ace8 r6: 0x3f28dfe0 r7: 0x2fe0dc84
r8: 0x2fe0dd60 r9: 0x0012ca70 r10: 0x00000001 r11: 0x00000000
ip: 0x00000148 sp: 0x2fe0dc78 lr: 0x32c40f5b pc: 0x35d7732c
cpsr: 0x00000010
接下來,我刪除了原來的應用程序,並把它放在iPhone通過的Xcode 4,我試圖運行這種方式,它墜毀與此錯誤:
2012-03-09 22:05:23.980 App[15930:707] Unresolved error in persistentStoreCoordinator Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x199a10 {URL=file://localhost/var/mobile/Applications/B7B2F695-B599-40A3-8D5A-88E1B7E1C148/Documents/App.sqlite, metadata=<CFBasicHash 0x17a8a0 [0x3ef4c630]>{type = immutable dict, count = 7,
entries =>
2 : <CFString 0x17eb10 [0x3ef4c630]>{contents = "NSStoreModelVersionIdentifiers"} = <CFArray 0x17ec10 [0x3ef4c630]>{type = immutable, count = 1, values = (
0 : <CFString 0x3ef409d0 [0x3ef4c630]>{contents = ""}
)}
4 : <CFString 0x17eb40 [0x3ef4c630]>{contents = "NSPersistenceFrameworkVersion"} = <CFNumber 0x1796d0 [0x3ef4c630]>{value = +386, type = kCFNumberSInt64Type}
6 : <CFString 0x17eb70 [0x3ef4c630]>{contents = "NSStoreModelVersionHashes"} = <CFBasicHash 0x17ece0 [0x3ef4c630]>{type = immutable dict, count = 2,
entries =>
1 : <CFString 0x3ef3df50 [0x3ef4c630]>{contents = "Camera"} = <CFData 0x17ec40 [0x3ef4c630]>{length = 32, capacity = 32, bytes = 0x497312a7c61a2dc8fe30e74ecc001ebc ... 1b5a15fa47a27413}
2 : <CFString 0x17ec30 [0x3ef4c630]>{contents = "Team"} = <CFData 0x17ec90 [0x3ef4c630]>{length = 32, capacity = 32, bytes = 0x401bd3f39f173666c4b24d43944d2562 ... 35b2b372c7051eed}
}
7 : <CFString 0x3ea9cf40 [0x3ef4c630]>{contents = "NSStoreUUID"} = <CFString 0x17e800 [0x3ef4c630]>{contents = "44E18608-E974-4E3D-A4F0-EB7C836869B4"}
8 : <CFString 0x3ea9cde0 [0x3ef4c630]>{contents = "NSStoreType"} = <CFString 0x3ea9cdf0 [0x3ef4c630]>{contents = "SQLite"}
9 : <CFString 0x17ebc0 [0x3ef4c630]>{contents = "_NSAutoVacuumLevel"} = <CFString 0x17ed40 [0x3ef4c630]>{contents = "2"}
10 : <CFString 0x17ebe0 [0x3ef4c630]>{contents = "NSStoreModelVersionHashesVersion"} = <CFNumber 0x157050 [0x3ef4c630]>{value = +3, type = kCFNumberSInt32Type}
}
, reason=Can't find model for source store}, {
URL = "file://localhost/var/mobile/Applications/B7B2F695-B599-40A3-8D5A-88E1B7E1C148/Documents/App.sqlite";
metadata = {
NSPersistenceFrameworkVersion = 386;
NSStoreModelVersionHashes = {
Camera = <497312a7 c61a2dc8 fe30e74e cc001ebc 6282715c 1751f100 1b5a15fa 47a27413>;
Team = <401bd3f3 9f173666 c4b24d43 944d2562 a3a17942 4bd878d0 35b2b372 c7051eed>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "44E18608-E974-4E3D-A4F0-EB7C836869B4";
"_NSAutoVacuumLevel" = 2;
};
reason = "Can't find model for source store";
}
我試圖替換字符串pathForResource在下面的方法與我最近的商店(Appv4)的確切名稱,但它告訴我,該數據庫的路徑爲空。
- (NSManagedObjectModel *)managedObjectModel {
if (managedObjectModel_ != nil) {
return managedObjectModel_;
}
NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"App" ofType:@"momd"];
NSURL *modelURL = [NSURL fileURLWithPath:modelPath];
managedObjectModel_ = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return managedObjectModel_;
}
在嘗試通過xcode在iPhone上多次運行應用程序後,它突然開始工作。但是,應用商店中的版本不會發生同樣的情況。
請幫忙!我無法弄清楚什麼是錯的。
編輯:這是我的AppDelegate.m文件
#import "AppAppDelegate.h"
#import "RootViewController.h"
@implementation AppAppDelegate
@synthesize window;
@synthesize navigationController;
//@synthesize managedObjectModel_, managedObjectContext_;
#pragma mark -
#pragma mark Application lifecycle
- (void)awakeFromNib {
RootViewController *rootViewController = (RootViewController *)[navigationController topViewController];
rootViewController.managedObjectContext = self.managedObjectContext;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the navigation controller's view to the window and display.
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
[self saveContext];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
}
/**
applicationWillTerminate: saves changes in the application's managed object context before the application terminates.
*/
- (void)applicationWillTerminate:(UIApplication *)application {
[self saveContext];
}
- (void)saveContext {
NSError *error = nil;
NSManagedObjectContext *managedObjectContext = self.managedObjectContext;
if (managedObjectContext != nil) {
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
/*
Replace this implementation with code to handle the error appropriately.
abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
*/
NSLog(@"Unresolved error in saveContext %@, %@", error, [error userInfo]);
abort();
}
}
}
#pragma mark -
#pragma mark Core Data stack
/**
Returns the managed object context for the application.
If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
*/
- (NSManagedObjectContext *)managedObjectContext {
if (managedObjectContext_ != nil) {
return managedObjectContext_;
}
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (coordinator != nil) {
managedObjectContext_ = [[NSManagedObjectContext alloc] init];
[managedObjectContext_ setPersistentStoreCoordinator:coordinator];
}
return managedObjectContext_;
}
/**
Returns the managed object model for the application.
If the model doesn't already exist, it is created from the application's model.
*/
- (NSManagedObjectModel *)managedObjectModel {
if (managedObjectModel_ != nil) {
return managedObjectModel_;
}
NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"App" ofType:@"momd"];
NSURL *modelURL = [NSURL fileURLWithPath:modelPath];
managedObjectModel_ = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return managedObjectModel_;
}
/*
Returns the persistent store coordinator for the application.
If the coordinator doesn't already exist, it is created and the application's store added to it.
*/
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (persistentStoreCoordinator_ != nil) {
return persistentStoreCoordinator_;
}
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"App.sqlite"];
NSError *error = nil;
//Auto update?
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
//
persistentStoreCoordinator_ = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) {
/*
Replace this implementation with code to handle the error appropriately.
abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
Typical reasons for an error here include:
* The persistent store is not accessible;
* The schema for the persistent store is incompatible with current managed object model.
Check the error message to determine what the actual problem was.
If the persistent store is not accessible, there is typically something wrong with the file path. Often, a file URL is pointing into the application's resources directory instead of a writeable directory.
If you encounter schema incompatibility errors during development, you can reduce their frequency by:
* Simply deleting the existing store:
[[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil]
* Performing automatic lightweight migration by passing the following dictionary as the options parameter:
[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES],NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details.
*/
NSLog(@"Unresolved error in persistentStoreCoordinator %@, %@", error, [error userInfo]);
abort();
}
return persistentStoreCoordinator_;
}
#pragma mark -
#pragma mark Application's Documents directory
/**
Returns the URL to the application's Documents directory.
*/
- (NSURL *)applicationDocumentsDirectory {
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[managedObjectContext_ release];
[managedObjectModel_ release];
[persistentStoreCoordinator_ release];
[navigationController release];
[window release];
[super dealloc];
}
@end
有一個開發者賬戶,你每年有一次免費門票讓代碼審查由蘋果公司完成,他們幫助您找到並消除錯誤。沒有看到你的整個應用程序,並得到你想要做什麼的詳細描述,這是很難消除的錯誤 – klaustopher 2012-03-10 21:32:52
如果你願意看看我的代碼,你需要看什麼? AppDelegate文件? – Egdod 2012-03-10 21:35:24