When using Swift REPL, the NSBundle.mainBundle() path actually points to:
/Applications/Xcode6-Beta6.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources
You may need to use NSFileManager :
let manager = NSFileManager.defaultManager() if manager.fileExistsAtPath("/Users/tsypa/a.txt") { // file exists, read } else { // file doesn't exist }
Note. . In fact, you automatically expand the tilde along the way to avoid hard coding the user's full home path:
"~/a.txt".stringByExpandingTildeInPath
source share