奇怪的应用程序崩溃在iPhone - 不被苹果拒绝 [英] Strange app crash on iPhone - not rejected by Apple

查看:814
本文介绍了奇怪的应用程序崩溃在iPhone - 不被苹果拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近通过iTunes Connect向苹果提交了我的应用,现在它已经在iTunes商店。然而,当我下载到朋友的iPhone,它立即崩溃。我在iPhone模拟器和我的iPad上测试了它(我没有iPhone)。所以,我把iPhone插入我的电脑,并得到这个崩溃日志从它:

I recently submitted my app to Apple through iTunes Connect, and it is now in the iTunes store. However, when I downloaded it onto a friend's iPhone, it crashes immediately. I tested it on the iPhone simulator and my iPad (I don't have an iPhone). So, I plugged the iPhone into my computer and got this crash log from it:

            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

接下来,我删除了原来的应用程序,并把它通过xcode 4在iPhone上。我试图运行它的方式,错误:

Next, I deleted the original app and put it on the iPhone through xcode 4. I tried running it this way, and it crashed with this error:

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),但它告诉我数据库的路径为空。

I tried replacing the string for pathForResource in the following method with the exact name of my most recent store (Appv4), but it tells me that the path for the database is null.

- (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上多次运行应用程序后,开始工作。但是,应用商店中的版本不会出现同样的情况。

After trying to run the application several times on the iPhone through xcode, it suddenly started working. However, the same does not occur for the version on the app store.

请帮助!我不知道什么是错的。

Please help! I can't figure out what is wrong.

编辑:这是我的AppDelegate.m文件

Here is my AppDelegate.m file

#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


推荐答案

您可以尝试这样:无法找到源存储的模型。根据作者,无法找到源存储的模型意味着您的对象模型和生成/编码的模型代码不同步,或者您的数据库未正确迁移/升级到新版本。他建议使用这个代码:

You might try this: Can’t find model for source store. According to the author, "Can't find model for source store" "means that either your object model and generated/coded model codes are out of sync or your db is not migrated/upgraded correctly to the new version." He recommends using this code:

 NSDictionary *optionsForSTore = [NSDictionary dictionaryWithObjectsAndKeys: 

 [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,

 [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

这篇关于奇怪的应用程序崩溃在iPhone - 不被苹果拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆