App Store升级安装删除文件

时间:2014-10-14 21:54:08

标签: iphone install store

StackOverflow的:

我需要帮助。我在应用程序商店中有一个应用程序收集用户输入(文本)并将其保存到应用程序沙箱的Documents文件夹中的存档文件(NSKeyedArchiver)。数据在NSKeyedUnarchiver发布时进行翻新。这个过程一直运行良好,可以进行多次更新。我刚刚向iTunes Store发布了该应用程序的更新,我让人们声称他们的数据已经消失。我的问题是我无法再现失败。

我现在拥有该应用程序的iPhone和iPad版本,在iPhone版本中,我将旧文件名重命名为iPad使用的相同名称;这是在didFinishLaunchingWithOptions:

中完成的
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    . . .
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    // get full path to Document subdirectory
    NSString *documentFolder = [paths objectAtIndex:0];

    // form full path for both old and new archive filenames
    self.archiveFile = [documentFolder stringByAppendingPathComponent:oldArchiveName];
    NSString *newArchive = [documentFolder stringByAppendingPathComponent:newArchiveName];
    NSLog(#” *** self.archiveFile (%@)”,self.archiveFile);
    NSLog(#” *** newArchive (%@)”,newArchive);

    // let’s rename the archive
    NSFileManager *fm = [NSFileManager defaultManager];
    // if the old archive filename exists change it to the new name
    if([fm fileExistsAtPath:self.archiveFile])
        (void)[fm moveItemAtPath:self.archiveFile toPath:newArchive error:nil];

    // self.archiveFile now points to the new archive file
    self.archiveFile = newArchive;
    NSLog(#” *** self.archiveFile (%@)”,self.archiveFile);
    . . .
}

从Xcode设备窗口的控制台子窗口中:

  

Oct 14 14:02:46 Randy-Merritts-iPad phoneFilebox [11096]:   *** self.archiveFile(/var/mobile/Containers/Data/Application/3BF0757B-96F4-4AAA-9CEB-6C87505CA6BD/Documents/cabself.xobeliF)

     

Oct 14 14:02:46 Randy-Merritts-iPad phoneFilebox [11096]:   *** newArchive(/var/mobile/Containers/Data/Application/3BF0757B-96F4-4AAA-9CEB-6C87505CA6BD/Documents/iFilebox.cabinet)

     

Oct 14 14:02:46 Randy-Merritts-iPad phoneFilebox [11096]:   *** self.archiveFile(/var/mobile/Containers/Data/Application/3BF0757B-96F4-4AAA-9CEB-6C87505CA6BD/Documents/iFilebox.cabinet)

我的用户提出的投诉表明该应用尝试打开'self.archiveFile'失败(如果在文档中找不到存档,则表示您是新用户,我创建了一个空存档,准备接收新数据)。而且问题在于:它永远不会对我失败。此外,安装新更新后,您可以输入新数据,终止应用程序,重新启动应用程序,并且所有(新)数据都在那里。如果我对如何取消归档数据存在编程缺陷,那么这种失败不会重复吗?

我已经使用Xcode 6.0.1 Devices窗口安装新版本以及www.diawi.com将测试版本分发给团队成员,我们都没有丢失任何数据;注意这两种方法严格执行更新;他们没有(也没有任何理由)打扰Documents子目录。

但是,我们可以通过从App Store下载副本来重现数据丢失问题。 App Store下载/设备内应用程序更新过程似乎正在重置Document文件夹并删除任何以前的文件。

有没有人见过这个?有人知道这个问题吗?为什么要从App Store安装升级

1 个答案:

答案 0 :(得分:0)

我在最近制作的应用升级上遇到了类似的问题。 我在Documents文件夹中保存.epub和.pdf文件。 用户报告说,升级后,应用程序找不到这些内容。 在我看来,文件在升级过程中被删除,或者出于任何原因,应用程序无法访问它们。

我无法重现这个问题。 我通常使用Testflight从Xcode进行分发或安装。 用户在ios7和ios8设备上报告了该问题。

我还没有找到原因,但这里是我所遵循的线索:

  1. 访问Documents文件夹是通过绝对路径完成的 不是我的情况,如果是这样,它也应该在Testflight升级时发生。 请参阅相关内容:First App Update, User Data Lost (was stored in Documents directory)

  2. 改变开发团队的应用程序。 我就是这种情况,因为我之前已将应用程序从一个开发人员帐户移动到另一个开发人员帐户 但据我所知,iOS应该将旧的Documents文件夹的内容移动到新的文件夹中 请参阅相关的跨更新管理数据部分:https://developer.apple.com/library/ios/technotes/tn2285/_index.html

  3. 文件的NSURLIsExcludedFromBackupKey使用不正确。 我把它设置为是。 这篇文章iOS App update new version delete files from Documents folder似乎暗示在升级时可能无法复制以这种方式标记的文件 请参阅"如果您标记文件以使其从备份中排除,那么这意味着可以轻松替换该文件。当您安装应用更新时,这些文件不会被复制到更新的应用&# 34; Haven在任何Apple文档

  4. 中都没有找到任何确认
  5. 还与NSURLIsExcludedFromBackupKey设置有关。 如果激活iCloud并将此设置设置为No,则可能会通过iCould删除此文件。 请参阅ios8 iCloud问题http://www.macrumors.com/2014/09/29/reset-all-settings-icloud-drive-bug/ 我也不是这样,因为用户报告了ios7上的问题。

  6. 上述任何一种听起来都不熟悉您的实施吗?