【问题标题】:ios Application Permission denied update appios应用程序权限被拒绝更新应用程序
【发布时间】:2013-07-17 09:14:55
【问题描述】:

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

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

我了解到此错误是由于我尝试安装具有相同 bundleId 的应用程序,该应用程序已存在于设备上。我不明白,因为我正在尝试模拟更新。

我该怎么做才能让它工作?

【问题讨论】:

  • 似乎使用存档和iTunes同步进行更新,而不是直接从xcode工作构建,但我不知道数据是否已经存在......像这样调试并不实际。 ..

标签: ios xcode permissions


【解决方案1】:

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

  • 构建存档并使用 iTunes 安装它,而不是使用 xcode 直接构建。
  • 另一个问题是,当 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 不一样,所以找不到数据 ;) 现在一切都很好,我可以取回我的数据了!

【讨论】:

    猜你喜欢
    • 2018-01-09
    • 2017-09-06
    • 2021-07-30
    • 2013-05-12
    • 1970-01-01
    • 2016-09-15
    • 2013-12-21
    • 2021-09-04
    相关资源
    最近更新 更多