title: NSBundle.mainBundle().pathForResource returns nil
body: <p>I am trying to write a simple IO wrapper for Swift.</p>
  
  <p>To test this I have a file named "Test.txt" in my project root.</p>
  
  <p>I have added this file to Build Phases within Build Bundle Resources, as suggested by everyone else who has had this problem.</p>
  
  <p><img src="https://i.stack.imgur.com/urzyj.png" alt="Build Bundle Resources"></p>
  
  <p>I have implemented a very simple File class with one read function with the intent to output the contents of the file.</p>
  
  <pre><code>class File2{
      let resourceName: String
      let type: String
      let bundle = NSBundle.mainBundle()
  
  
      init(resourceName: String, type: String = "txt"){
          self.resourceName = resourceName
          self.type = type
          println(self.bundle)
      }
  
      func read(){
          let path = self.bundle.pathForResource("Test.txt", ofType: "txt") //Hard coded these in just to make sure Strings contained no whitespace
          println(path) //This returns nil...why?
          var error:NSError?
          //print(String(contentsOfFile:path!, encoding:NSUTF8StringEncoding, error: &amp;error)!)
          //return String(contentsOfFile:path!, encoding:NSUTF8StringEncoding, error: &amp;error)!
      }
  }
  </code></pre>
  
  <p>When I print the contents of the bundle I get a URI to a specific location on my filesystem, which I assume is the virtual location of the app in the simulator. Navigating to it reveals that it does indeed contain my "Test.txt" file.</p>
  
  <p>Now all I want to do is get the path to that file.</p>
  
  <p>I do this by calling: <code>self.bundle.pathForResource("Test.txt", ofType: "txt")</code></p>
  
  <p>This returns "nil"</p>
  
  <p><strong>Why? :)</strong></p>