xcode ios files not recognized in bundle
Asked Answered
U

2

9

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!

Upper answered 13/4, 2012 at 3:22 Comment(2)
check if your file exists in the .app folder productDeath
Better yet, check if it is being included in the 'Copy Bundle Items' phase in 'Build PhasesDemitasse
D
12

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.

Demitasse answered 13/4, 2012 at 3:30 Comment(4)
This is especially nasty in XCode 4.3. I never noticed it in XCode 4.2. However, it reliably does NOT add audio or video files when I add them. HTML files and image files however, DO get added to the target when I drag them in.Angi
Yeah, I've noticed that too. It gets annoying when using many controls and projects, because then you get a mountain of linker errors.Demitasse
Even plists seem to be a problem. If I rename the plist to png it will copy.Geryon
One other point that I have found, even in Xcode 8 - it is helpful to clean your project when you are having issues with files not being found in your bundle.Undercover
G
1

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.

Geryon answered 3/2, 2013 at 0:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.