I am not sure whether this is expected or it is bug.
I am trying to create the same folder structure in disk as that in XCode. I use the following steps to add resource files to my project:
- Create a
Resources
folder under the root folder of the project.
- Drag the
Resources
folder to XCode, which creates a Group
for the folder.
- Drag my resource files from
Finder
to the Resources
folder in XCode.
And now I can see all the resource files are listed in Build Phrases
->Copy Bundle Resources
.
The weird thing is that [[NSBundle mainBundle] pathForResource:@"book" ofType:@"epub"]
returns a file path that can be located, while [[NSBundle mainBundle] pathForResource:@"book" ofType:@"epub" inDirectory:@"Resources"]
returns (null)
.
From the Build Results
window, I notice this line:
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
which shows that Resources/book.epub
file is indeed copied to MBookReader.app/
(the root directory of the app bundle).
Now Resources
is a real folder in disk, why the folder itself is not copied?
PS. I am using XCode 4.3.2.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…