Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 796
manuelBetancurt Avatar asked Apr 13 '12 03:04

manuelBetancurt


2 Answers

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.

like image 143
CodaFi Avatar answered Oct 16 '22 12:10

CodaFi


The answer marked as correct might not be right in all situations. If you have e.g. 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.

like image 29
brainray Avatar answered Oct 16 '22 10:10

brainray