ios应用程序权限被拒绝更新应用程序

时间:2013-07-17 09:14:56

标签: ios xcode permissions

我有一个现有的应用程序(在appStore中可用),我想从头开始重新启动,并将其作为更新。所以我开始了一个新项目,并像旧项目一样重现所有(name,bundleId,xcdatamodel等)。

我想测试当我使用新应用程序更新旧应用程序时是否保存了数据,但是当我构建它时,我从xcode“应用程序权限被拒绝”中得到此错误。

我读到这个错误是因为我尝试使用设备上已存在的相同bundleId安装应用程序。我不明白,因为我正在尝试模拟更新。

我能做些什么才能让它发挥作用?

1 个答案:

答案 0 :(得分:0)

好的,这是帮助我的解决方案。

  • 使用iTunes而不是xcode direct build构建存档并安装它。
  • 另一个问题是,该应用程序的第一个版本是在xcode可用时为第一个iPad构建的,但这些设备尚未售出。这是旧的 - (NSPersistentStoreCoordinator *)persistentStoreCoordinator方法:

-(NSPersistentStoreCoordinator *)storeCoorditator{
    if(storeCoorditator){
        return storeCoorditator;
    }

    storeCoorditator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self objectModel]];
    NSError *lc_error = nil;

    NSString *lc_path = [NSString stringWithFormat:@"%@/data.sqlite",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]];

    NSURL *storeUrl = [NSURL fileURLWithPath:lc_path];

    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                             [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                             [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

    [storeCoorditator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&lc_error];
    return storeCoorditator;
}

以下是我尝试使用的方法:


-(NSPersistentStoreCoordinator *)persistentStoreCoordinator{
    if (_persistentStoreCoordinator != nil) {
        return _persistentStoreCoordinator;
    }

    NSURL *storeUrl = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"PDF.sqlite"];

    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                             [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                             [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
    NSError *error = nil;
    _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
    if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) {

        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }

    return _persistentStoreCoordinator;
}

由于storeUrl不相同,无法找到数据;) 现在一切都很好,我可以恢复我的数据!

相关问题