我不确定这是预期还是错误.我试图在磁盘中创建与XCode相同的文件夹结构.我使用以下步骤将资源文件添加到我的项目:
Resources
在项目的根文件夹下创建一个文件夹.Resources
文件夹拖到XCode,Group
为该文件夹创建一个.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
Run Code Online (Sandbox Code Playgroud)
这表明Resources/book.epub
文件确实被复制到MBookReader.app/
(应用程序包的根目录).
现在Resources
是磁盘中的真实文件夹,为什么不复制文件夹本身?
PS.我正在使用XCode 4.3.2.
我的朋友带着一个创建视频组合应用程序的小请求来找我.我认为这是尝试Swift的一个很好的借口,这就是我所做的.(该应用不适合在应用商店发布,只能通过Testflight分发)
我遇到了一些麻烦,我在尝试运行我的项目时遇到以下错误:
An error was encountered while running (Domain = NSPOSIXErrorDomain, Code = 22)
Run Code Online (Sandbox Code Playgroud)
在我的"Bundle Resources"中将带有.mp4视频文件的目录添加到我的项目后出现错误.它涉及6个.mp4文件,总共约1.2gb.
由于我无法弄清楚为什么错误发生在一开始,我决定重新做我的整个项目(复制点点滴滴).该项目一直运行到我添加包含视频的文件夹的部分.
我已经尝试删除引用和文件夹,但错误包括.我真的想深究这一点,所以我不必创建一个新项目,我可以删除任何创建问题的文件.
提前致谢.
当我尝试在模拟器上运行我的应用程序时,一切正常.但是当我尝试构建它以在真实设备上测试它时,我收到以下错误:
CodeSign /Users/fvoordeckers/Library/Developer/Xcode/DerivedData/MyProject-##########/Build/Products/Debug-iphoneos/MyProject.xctest
cd /Users/fvoordeckers/Documents/Projecten/MyProject/iOS
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Signing Identity: "iPhone Developer: Frederik (########)"
/usr/bin/codesign --force --sign ##################/Users/fvoordeckers/Library/Developer/Xcode/DerivedData/MyProject-##########/Build/Products/Debug-iphoneos/MyProject.xctest
/Users/fvoordeckers/Library/Developer/Xcode/DerivedData/MyProject-##########/Build/Products/Debug-iphoneos/MyProject.xctest: bundle format unrecognized, invalid, or unsuitable
Command /usr/bin/codesign failed with exit code 1
Run Code Online (Sandbox Code Playgroud)
我已经更改了ID #
.我创建了一个配置文件,其中包括我正在使用的设备以及所需的证书.它似乎没有应用程序的问题,但使用xctest ...我也尝试在签名配置中添加'--deep'标志,但它没有帮助...