How can I trigger the Full Disk Access prompt to write to a raw block device?

I want to write a disk image (ISO, img) to an SD card, but I always get permission errno 13 (permission denied).

            let diskPath = "/dev/rdisk99"
            guard let diskHandle = FileHandle(forWritingAtPath: diskPath) else {
                throw NSError(domain: "DiskWriter", code: Int(errno), userInfo: [NSLocalizedDescriptionKey: "errno \(errno)"])
            }

It seems that when other macOS applications try to read from a raw block device it triggers an Access Removable Media prompt and when other applications try to write to a raw block device it triggers a Full Disk Access prompt.

How can I trigger that prompt? And then how do I elevate my write to use that permission?

P.S. I'm not a Swift coder, but I'd like to be... if it weren't that every "simple" thing I've tried launches me directly into a brick wall. :slight_smile:

What I've tried

  • I did change Sandbox App to NO in MyApp.entitlements
  • I have tried manually adding my Debug Archive to Full Disk Access

Why?

As to why I'm I interested in this: Well, it just seems silly that UI tools that do what dd does are hundreds of megabytes. Can't we do this in a UI that uses all the default macOS libraries and is just a few kilobytes (or megabytes at worst)?

Update: notes to self:

This is very specific to the Mac, whereas the focus of Swift Forums is the Swift language itself. I recommend that you ask it over an Apple Developer Forums and I’ll try to help you there. Put your thread in App & System Services > Core OS and tag it with Files and Storage. That’ll make sure I see it.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

4 Likes