0

Looking through SO it appears that the Application Support folder is not created on simulators by default:

iOS: Can't save file to 'Application Support' folder, but can to 'Documents'

But is it created on devices? Or do we need to createDirectory for applicationSupportDirectory, and when we use

fileManager.createDirectory(at: applicationSupportURL, withIntermediateDirectories: true, attributes: nil)

are we guaranteed that if there are files within the folder that they are not deleted? I can't find a reference in the documentation for either question.

WishIHadThreeGuns
  • 1,225
  • 3
  • 17
  • 37

2 Answers2

3

You are always responsible for creating the directory.

A convenient way is the API to get the current URL with set create parameter.

let applicationSupportDirectoryURL = try! fileManager.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
vadian
  • 274,689
  • 30
  • 353
  • 361
-1

I can confirm the same on iOS 16 simulator under Xcode 14. On first run "Application Support" seems not existent and vadian code fixes correctly.

ingconti
  • 10,876
  • 3
  • 61
  • 48