Why user consent is not thrown in Catalina while trying to access Downloads folder, it is silently failing in background

I am using below code to trash an item


do {

try FileManager.default.trashItem(at: NSURL(fileURLWithPath: "/Users/syamalacat/Downloads/Doc.docx") as URL, resultingItemURL: nil)

} catch {

print(error)

}

I dont see Downloads under xcode application to check the box in Files and Folders in System Preferences pane, but it is just throwing below error


Error Domain=NSCocoaErrorDomain Code=513 "“Doc” couldn’t be moved to the trash because you don’t have permission to access it." UserInfo={NSURL=file:///Users/syamalacat/Downloads/Doc.docx, NSUserStringVariant=(

Trash

), NSUnderlyingError=0x600000c6fed0 {Error Domain=NSOSStatusErrorDomain Code=-5000 "afpAccessDenied: Insufficient access privileges for operation "}}


From Files and Folders , i am not able to add Downloads folder, it is greyed out

Even for the first time i am not able to see user consent message


Note: I am running my application from xcode itself

Replies

IIRC Downloads is covered by Files and Folders.

From Files and Folders, i am not able to add Downloads folder, it is greyed out

The interface to add an item isn’t expecting a folder, but rather an app that will be granted access to all the various folders.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"