相关疑难解决方法(0)

子目录中的资源文件将复制到应用程序包的根目录

我不确定这是预期还是错误.我试图在磁盘中创建与XCode相同的文件夹结构.我使用以下步骤将资源文件添加到我的项目:

  1. Resources在项目的根文件夹下创建一个文件夹.
  2. Resources文件夹拖到XCode,Group为该文件夹创建一个.
  3. 将我的资源文件拖到XCode中FinderResources文件夹.

现在我可以看到Build Phrases- > 中列出了所有资源文件Copy Bundle Resources.

奇怪的是[[NSBundle mainBundle] pathForResource:@"book" ofType:@"epub"]返回一个可以定位的文件路径,同时[[NSBundle mainBundle] pathForResource:@"book" ofType:@"epub" inDirectory:@"Resources"]返回(null).

Build Results窗口,我注意到这一行:

CpResource MBookReader/Resources/book.epub /Users/neevek/Library/Developer/Xcode/DerivedData/workspace-fykuaikryknuhxgevcdtspkspptj/Build/Products/Debug-iphonesimulator/MBookReader.app/book.epub
cd /Users/neevek/workspace/xcode_projects/MBookReader
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip /Users/neevek/workspace/xcode_projects/MBookReader/MBookReader/Resources/book.epub /Users/neevek/Library/Developer/Xcode/DerivedData/workspace-fykuaikryknuhxgevcdtspkspptj/Build/Products/Debug-iphonesimulator/MBookReader.app
Run Code Online (Sandbox Code Playgroud)

这表明Resources/book.epub文件确实被复制到MBookReader.app/(应用程序包的根目录).

现在Resources是磁盘中的真实文件夹,为什么不复制文件夹本身?

PS.我正在使用XCode 4.3.2.

directory resources xcode

22
推荐指数
1
解决办法
1万
查看次数

标签 统计

directory ×1

resources ×1

xcode ×1