I have the following code which creates a string array of a text file named num.txt
import Foundation
import UIKit
func linesFromResource(fileName: String) throws -> [String] {
guard let path = NSBundle.mainBundle().pathForResource("num", ofType: "txt") else {
throw NSError(domain: NSCocoaErrorDomain, code: NSFileNoSuchFileError, userInfo: [ NSFilePathErrorKey : fileName ])
}
let content = try String(contentsOfFile: path, encoding: NSUTF8StringEncoding)
return content.componentsSeparatedByString("\n")
}
let lines = try linesFromResource("num.txt")
print(lines)
my file num.txt is located in the resource folder of the playground

And it works fine and does what is intended, but when I try to do exactly the same thing in a project it gives me this error message:

For some reason in the project the file "num.txt" can't be called I've tried creating a Resources folder and putting the file there but it didn't work either, what am I doing wrong?

