My App has to download user profile images from some web URLs. Therefore, I'm creating an "images" folder in the user's "Documents" folder. Creating the folder works fine, also downloading and moving images to this folder.
Before creating I check whether the "images" folder exists.
var isDirectory: ObjCBool = ObjCBool.init(false)
fileManager.fileExists(atPath: imageFolder.absoluteString, isDirectory: &isDirectory)
if !isDirectory.boolValue { // directory does not exist
do {
try fileManager.createDirectory(at: imageFolder, withIntermediateDirectories: true, attributes: nil)
self.imageFolder = imageFolder
print("Created image folder.")
} catch let error {
print(error.localizedDescription)
}
}
On every app startup fileExists()
returns false
although the folder exists:
(lldb) po imageFolder
▿ file:///Users/[...]/CoreSimulator/Devices/CE56339A-2A1A-4105-97A6-828E96ADD341/data/Containers/Data/Application/C2CC9A93-E9A4-4069-9FB5-771DDAEAA454/Documents/images/
But imageFolder.checkResourceIsReachable()
returns true
.
(lldb) po imageFolder.checkResourceIsReachable()
true
The same is true for every other fileExists()
call -> always false
although file/folder exists.
Does anyone has experienced something similar? Any advices how to debug this error? FileManager bug!?