0

I am trying to create a directory inside Application Support in iOS

let fileManager = FileManager.default
    if let documentDirectory = fileManager.urls(for: .applicationSupportDirectory,
                                                in: .userDomainMask).first {
      let folderURL = documentDirectory.appendingPathComponent(storeName)
      if !fileManager.fileExists(atPath: folderURL.path) {
        do {
          try fileManager.createDirectory(atPath: folderURL.path,
                                          withIntermediateDirectories: true,
                                          attributes: nil)
        } catch {
          print(error.localizedDescription)
        }
    }

This code is called inside application(_:didFinishLaunchingWithOptions:). It fails to create the directory with the error

You don’t have permission to save the file in the folder “Application Support"

Anyone facing this issue?

Harish
  • 368
  • 2
  • 10
  • The error you posted would not come from the code you posted. Either post an exact copy and paste of the actual error (by adding `print(error)` to the `catch` block) or add the code where you actually try too save a file. – rmaddy Nov 11 '19 at 23:21
  • @rmaddy edited the question – Harish Nov 11 '19 at 23:27
  • Just do `print(error)` so you can see the full error. Post that full error. – rmaddy Nov 11 '19 at 23:35
  • Possible duplicate https://stackoverflow.com/questions/45993238/permission-denied-when-trying-to-create-a-directory-in-application-support?rq=1? – Tom Nov 12 '19 at 02:59

0 Answers0