我不确定这是预期的还是错误的。我正在尝试在磁盘中创建与 XCode 中相同的文件夹结构。我使用以下步骤将资源文件添加到我的项目中:
Resources
在项目的根文件夹下创建一个文件夹。- 将
Resources
文件夹拖到 XCode,它会Group
为该文件夹创建一个。 - 将我的资源文件拖到 XCode
Finder
中的文件夹中。Resources
现在我可以看到所有资源文件都列在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
这表明该Resources/book.epub
文件确实被复制到MBookReader.app/
(应用程序包的根目录)。
现在Resources
是磁盘中的一个真正的文件夹,为什么文件夹本身没有被复制?
PS。我正在使用 XCode 4.3.2。