title: Xcode Swift 3.0 macOS (Sierra) app unable to create file, no permission
body: <p>I'm fairly new to Xcode and Swift. I'm trying to create a file called "file.txt" in my Documents directory and getting the error "You don’t have permission to save the file."</p>
  
  <p>Ultimately, I DO NOT want to use the default Documents directory as I'm using FIFinderSyncController to watch everything ("/").</p>
  
  <pre><code>    let targetFile = (FIFinderSyncController.default().targetedURL()?.path)! + "/file.txt"
  
      NSLog("%@", targetFile as NSString)
  
      let fileManager = FileManager.default
      if fileManager.fileExists( atPath: (targetFile) ) == false {
  
          do {
              let targetString = (FIFinderSyncController.default().targetedURL()?.path)! + "/Untitled.txt"
  
              NSLog("%@", targetString as NSString)
  
              let fileManager = FileManager.default
  
              if fileManager.fileExists( atPath: targetString ) == false {
                  let content = "" // Just creating empty file.
  
                  //writing
                  try content.write(toFile: targetString, atomically: false, encoding: String.Encoding.utf8)
  
                  //reading
                  let readingText = try NSString(contentsOfFile: targetString, encoding: String.Encoding.utf8.rawValue)
  
                  NSLog("%@", readingText as NSString)
              }
          }
          catch {
              print(error.localizedDescription)
          }
      }
  </code></pre>
  
  <p>Log shows:</p>
  
  <pre><code>2017-04-06 13:35:46.450077-0700 Open New Text File[5177:1035580]     /Users/david/Documents/file.txt
  2017-04-06 13:35:46.450257-0700 Open New Text File[5177:1035580]     /Users/david/Documents/file.txt
  You don’t have permission to save the file “file.txt” in the folder “Documents”.
  </code></pre>