从 xcode 部署资源文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/388024/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
deploying resource files from xcode
提问by Akusete
How does one copy resource files (config/data/image) files to an applictions home directory on the iPhone.
如何将资源文件 (config/data/image) 文件复制到 iPhone 上的应用程序主目录。
A related question Loading Data Files on iPhone?, received an answer "just add them to your project; Xcode will copy them to the .app bundle when it builds your application".
一个相关的问题在 iPhone 上加载数据文件?,收到答复“只需将它们添加到您的项目中;Xcode 会在构建您的应用程序时将它们复制到 .app 包中”。
How does one do this? (If this is a simple question, a manual reference/page# is fine)
如何做到这一点?(如果这是一个简单的问题,手动参考/页面#就可以了)
I want to be able to copy a file onto the iPhone simulator and open it at runtime. I have tried to do this by adding 'copy file' targets, although I havent been able to find the files at runtime.
我希望能够将文件复制到 iPhone 模拟器并在运行时打开它。我试图通过添加“复制文件”目标来做到这一点,尽管我无法在运行时找到这些文件。
I know using property list, or sql lite database is prefered over file io, but I would still like to understand how to achieve this.
我知道使用属性列表或 sql lite 数据库比文件 io 更受欢迎,但我仍然想了解如何实现这一点。
采纳答案by frankodwyer
In my app, I have a sql lite DB which I just dropped in the root of my project folder and added to the resources folder of my project, and it winds up in the bundle, accessible by the app.
在我的应用程序中,我有一个 sql lite DB,我只是将它放在我的项目文件夹的根目录中并添加到我的项目的资源文件夹中,它在包中结束,可由应用程序访问。
http://img68.imageshack.us/img68/3047/xcoderesourceslw5.png
http://img68.imageshack.us/img68/3047/xcoderesourceslw5.png
I assume this will work for any file. I didn't have to write any special targets or operations.
我认为这适用于任何文件。我不必编写任何特殊的目标或操作。
In your app, this file then shows up as follows:
在您的应用程序中,此文件显示如下:
NSString *dbFilePath = [[NSBundle mainBundle]
pathForResource:@"dictionary"
ofType:@"db"];
回答by Akusete
I just found this site, Bundle Programming Guideit explains, how to access resources set in your project at runtime. I assume its just as easy to use single files.
我刚刚找到了这个站点,Bundle Programming Guide它解释了如何在运行时访问项目中设置的资源。我认为使用单个文件同样容易。