That error message is less than helpful. Does the current user have permissions to write to that directory, let alone to the file being replaced? if not, no amount of entitlements will let you do what you want.
—Rob > On Mar 14, 2021, at 3:43 AM, Allan Odgaard via Cocoa-dev > <[email protected]> wrote: > > I’ve tried something like the code below to save a file not owned by current > user. > > I have codesigned the application using hardened runtime and the > `com.apple.developer.security.privileged-file-operations` entitlement > (although this is outside App Store and no sandboxing). > > It doesn’t work and I see this error in the console: > `(libsystem_secinit.dylib) com.apple.secinitd.fileoperations: > xpc_pipe_routine() returned [5: Input/output error]` > > Does anyone know if, when, or how it is supposed to work? > > [NSWorkspace.sharedWorkspace > requestAuthorizationOfType:NSWorkspaceAuthorizationTypeReplaceFile > completionHandler:^(NSWorkspaceAuthorization* authorization, NSError* error){ > if(authorization) { > if([[NSFileManager fileManagerWithAuthorization:authorization] > replaceItemAtURL:originalURL withItemAtURL:tempURL backupItemName:nil > options:0 resultingItemURL:nil error:&error]) { > … > } > … > } > … > }]; > _______________________________________________ > > Cocoa-dev mailing list ([email protected]) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/petrock%40mac.com > > This email sent to [email protected] _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
