title: How to download a Pdf file in swift and find in file manager
body: <p>I have downloaded a pdf using code below. I am able to find the file in App Data Container, but from app data container my device needs Mac, x code or iTunes etc.</p>
  <p>Can I give a distinction path to Documents OR another place to find the pdf in iPhone files? I have an option to open the file with iBook but it is not there.</p>
  <p>My code to download the file is here:</p>
  <pre><code>func downloadFile(){
          let url = &quot;https://www.tutorialspoint.com/swift/swift_tutorial.pdf&quot;
          let fileName = &quot;MyFile&quot;
          
          savePdf(urlString: url, fileName: fileName)
        
      }
  
      func savePdf(urlString:String, fileName:String) {
              DispatchQueue.main.async {
                  let url = URL(string: urlString)
                  let pdfData = try? Data.init(contentsOf: url!)
                  let resourceDocPath = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)).last! as URL
                  let pdfNameFromUrl = &quot;YourAppName-\(fileName).pdf&quot;
                  let actualPath = resourceDocPath.appendingPathComponent(pdfNameFromUrl)
                  do {
                      try pdfData?.write(to: actualPath, options: .atomic)
                      print(&quot;pdf successfully saved!&quot;)
      //file is downloaded in app data container, I can find file from x code &gt; devices &gt; MyApp &gt; download Container &gt;This container has the file
                  } catch {
                      print(&quot;Pdf could not be saved&quot;)
                  }
              }
          }
  </code></pre>