NSBundle pathForResource is NULL

So here's the solution for this problem after I got the source:

I didn't really pay attention to the posted screenshot, but the target is of type "Command-line Tool"... and since those don't have a bundle [NSBundle mainBundle] of course returns nil. It's pretty misleading that Xcode doesn't complain that it can't execute the "Copy Bundle Resources" step, it just silently skips it.

Solution is simply to add a new target, of type "Application" so a bundle-based application is generated. Then check the Target Membership checkboxes for all sources and resources for this new target. The plist paths are correctly resolved then.


I was trying to get my iPhone app to use a default sqlite database and the darn app couldn't find it. Turned out that I had to make sure that the .sqlite file was in the bundle resource.

  1. Select your project
  2. Select Target
  3. Select Build Phases tab
  4. Open the section labelled "Copy Bundle Resources"
  5. Drag and drop your .sqlite file into this section.

now your app will find this default sqlite database.