FileManager returns permission error while trying to get the file size, in iOS 13 devices.
do {
let attr = try FileManager.default.attributesOfItem(atPath: my_file_path) //--> Getting nil
fileSize = attr[FileAttributeKey.size] as! UInt64
} catch {
print("Error: \(error)")
}
Error returned:
Error Domain=NSCocoaErrorDomain Code=257 "The file “trim.1A9FFC19-EE2C-438A-BF3D-97E05A97EF9E.MOV” couldn’t be opened because you don’t have permission to view it." UserInfo={NSFilePath=/private/var/mobile/Containers/Data/PluginKitPlugin/ADB8684E-12B5-451D-A20F-158B899BB3DD/tmp/trim.1A9FFC19-EE2C-438A-BF3D-97E05A97EF9E.MOV, NSUnderlyingError=0x280af0510 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
The issue observed only after I updated to iOS 13. In earlier versions everything is working fine.