简体   繁体   English

可以从主捆绑中删除文件吗?

[英]is possible Remove file from main bundle?

I have created a sqlite file and added it into the mainBundle of my Xcode project. 我创建了一个sqlite文件并将其添加到我的Xcode项目的mainBundle中。 This file gets copied to document directory from main bundle on app launch. 应用程序启动时,此文件将从主程序包复制到文档目录。 Is there a possibility to remove the file from my mainBundle after i copied it to the document directory ? 在将文件复制到文档目录后,是否有可能从mainBundle中删除该文件?

From within an official application, you can't - the app bundle is read-only. 在官方应用程序中,您不能 - 应用程序包是只读的。

If you are running on a jailbroken device and you manage to give root access to your executable, then you can. 如果您在越狱设备上运行并且您设法为您的可执行文件提供root访问权限,那么您可以。

Is is impossible. 是不可能的。 What's more, if you copy too much data from main bundle to document directory, you may be rejected by app store because iCloud will backup the data in document directory. 更重要的是,如果您将大量数据从主数据包复制到文档目录,您可能会被应用商店拒绝,因为iCloud将备份文档目录中的数据。 I have ever been rejected for this reason. 我因此而遭到拒绝。 You can copy the data to cached directory instead. 您可以将数据复制到缓存目录。

Basically in an app you developed a logic that on run time you need to delete some resource from NSBundle time(which is through coding).As initailly the application is run on simulator by most developers.it will work perfectly with no issue. 基本上在一个应用程序中你开发了一个逻辑,在运行时你需要从NSBundle时间删除一些资源(这是通过编码)。最初,大多数开发人员都在模拟器上运行应用程序。它将完美无缺地运行。

But when you run the same application on device ie iPhone/iPad it will show a error i,e NSCocoaErrorDomain = 513. 但是当你在设备上运行相同的应用程序,即iPhone / iPad时,它会显示错误,即NSCocoaErrorDomain = 513。

What it means is that on runtime in device the bundle has only read permisson not write. 这意味着在设备的运行时,bundle只有读取权限而不能写入。 So when designing the applications do not include logic that deletes the resource from NSBundle on run time because it will work perfectly in iPhone/iPad simulator. 因此,在设计应用程序时,不包括在运行时从NSBundle中删除资源的逻辑,因为它可以在iPhone / iPad模拟器中完美运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM