title: How can I write a file in a folder located at Apple's Files App in SwiftUI?
body: <p>I followed the Swift project UsingFiles <a href="https://github.com/timrichardsn/Supporting-Files-in-iOS-11/blob/master/UsingFiles/ViewController.swift" rel="nofollow noreferrer">github</a> and its <a href="https://www.youtube.com/watch?v=p1UNnsodJxc" rel="nofollow noreferrer">video</a> to write files in my SwiftUI project. The project UsingFiles can write files to Files APP and then the writing files can be seen in the Files APP. But I followed the code as following, the files cannot be seen in Files APP.</p>
  
  <pre><code>let file = "\(UUID().uuidString).txt"
  let contents = "Some text..."
  
  let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
  let fileURL = dir.appendingPathComponent(file)
  
  do {
      try contents.write(to: fileURL, atomically: false, encoding: .utf8)
  }
  catch {
      print("Error: \(error)")
  }
  </code></pre>
  
  <p>The UsingFiles writing files is <code>file:///Users/fmac/Library/Developer/CoreSimulator/Devices/11111111-881E-488A-9571-E61B83EB6062/data/Containers/Data/Application/11111111-AF89-4B15-B3B5-E13A63A19F8D/Documents/E018F056-83EA-4D70-87C4-16F755AA404A.txt</code>. </p>
  
  <p>My writing files is <code>file:///Users/fmac/Library/Developer/CoreSimulator/Devices/11111111-881E-488A-9571-E61B83EB6062/data/Containers/Data/Application/11111111-B191-4ACD-98B1-004E619C2EC7/Documents/C9E0F52E-040F-4647-94A3-88E0DA171AB5.txt</code></p>
  
  <p>I can find the writing files of UsingFiles in the directory <code>UsingFiles</code> as following:
  <a href="https://i.stack.imgur.com/127ft.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/127ft.jpg" alt="enter image description here"></a></p>
  
  <p>But I cannot find the writing file in Files APP in my SwiftUI project. Is there something wrong of the code in SwiftUI? Why I cannot find the writing file in Files APP？</p>