Search code examples
objective-cresourcebundlensbundle

Objective C not finding file in resources folder


I'm trying to access a file in my resources folder as follows:

NSLog(@"%@",defaultPlistName);
NSString *pListPath = [[NSBundle mainBundle] pathForResource:defaultPlistName ofType:@"plist"];
NSLog(@"pListPath: %@ ",pListPath);

This is the output:

2015-03-13 10:08:43.078 MyApp[628:214709] DefaultConfig
2015-03-13 10:09:26.560 MyApp[628:214709] pListPath: (null) 

A file named "DefaultConfig.plist" exists in the resource folder.

Why isn't this file being found?


Solution

  • Check the Copy Bundle Resources for your target to make sure the file has been added properly.

    Usually, when when adding a new file, you can choose the targets when creating the file. Also, for each file you can add/remove the file from targets via the Utilities Pane.

    enter image description here