简体   繁体   中英

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,

it shows ok on the project navigator, I give it show in finder, and confirm the file exists in the project

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. 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. A workaround is to rename your plist to .png and then rename it back later.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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