简体   繁体   English

xcode ios文件无法在捆绑中识别

[英]xcode ios files not recognized in bundle

i want to play a video, but i noticed that my files are not importing to the bundle?? 我想播放视频,但我注意到我的文件没有导入到捆绑包?

so I just drag and drop the AA.mp4 file to my project, 所以我只是将AA.mp4文件拖放到我的项目中,

it shows ok on the project navigator, I give it show in finder, and confirm the file exists in the project 它在项目导航器上显示ok,我在finder中显示它,并确认该项目中存在该文件

now, when i try this 现在,当我试试这个

 NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
    NSFileManager *fm = [NSFileManager defaultManager];
    NSArray *dirContents = [fm contentsOfDirectoryAtPath:bundleRoot error:nil];

    NSLog(@"content of bundle ::%@", dirContents);

to see the contents of my bundle, i see every other file, but not the one i have imported??? 看到我的包的内容,我看到每个其他文件,但不是我导入的文件???

so what im i missing? 那么我错过了什么?

thanks! 谢谢!

Simply dropping a file into an Xcode project is not enough. 简单地将文件放入Xcode项目是不够的。 You must check your app target as the one receiving the file in the dialog box, else it will not be added to the 'copy bundle phase' and as a result, not copy over to your app. 您必须将应用目标检查为在对话框中接收文件的目标,否则不会将其添加到“复制捆绑阶段”,因此不会复制到您的应用。 Go into build phases and drag your video into the copy bundle resources phase group, then clean and run again. 进入构建阶段并将视频拖到复制包资源阶段组中,然后清理并再次运行。

Though if you can see it's name in red in the file tree, it doesn't exist. 虽然如果您可以在文件树中看到它的名称为红色,但它不存在。

The answer marked as correct might not be right in all situations. 在所有情况下,标记为正确的答案可能不正确。 If you have eg plists, Xcode 4.5+ will for some reason NOT copy it to the application bundle, even if everything else is right. 如果您有例如plists,Xcode 4.5+将由于某种原因不将其复制到应用程序包中,即使其他一切都是正确的。 A workaround is to rename your plist to .png and then rename it back later. 解决方法是将plist重命名为.png,然后稍后将其重命名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM