Non-Sandboxed App built with Xcode could read directory in Big Sur not Monterey

Error Domain=NSCocoaErrorDomain Code=257 "The file “ReceiptScans” couldn’t be opened because you don’t have permission to view it." UserInfo={NSURL=file:///Users//Documents/ReceiptScans, NSFilePath=/Users//Documents/ReceiptScans, NSUnderlyingError=0x60000178e280 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}

I turned off sandboxing to make this work in Big Sur with Xcode 13.1 beta, but when I upgraded to Monterey and Xcode 13.1 I started getting the error again.

let files: [URL] = try FileManager.default.contentsOfDirectory(at: path, includingPropertiesForKeys: nil, options: [FileManager.DirectoryEnumerationOptions.skipsHiddenFiles])

I checked and sandboxing is still turned off. I cleaned the build directory and recompiled. Can't make it work. Have the permissions been changed? Have some API's been changed?

Because sandboxing is turned off I don't think I should have to use any special entitlements.

The fact that this is failing with EPERM even though App Sandbox is disabled means its very likely you’re hitting a MAC limit. See the discussion is On File System Permissions.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

If you create a new test app that tries to read the same file, does it fail in the same way?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@DTS Engineer This appears to be the same issue I have encountered using a new test app. Posted here.

Non-Sandboxed App built with Xcode could read directory in Big Sur not Monterey
 
 
Q