Struggling to understand why acl_free crashes in Swift

Can anyone give me any pointers? My GoogleFU is broken.

https://developer.apple.com/forums/thread/741584

I have no clue, but try asking an AI… :slight_smile:

I’ve been using AI for things I’d google for and it’s amazingly good! Works great for regex and creating functions too!

1 Like

Heh. I like the reply from the Apple Developer:

It’s like you went out of your way to choose one of weirdest dark’n’dusty corners of the ecosystem. Why couldn’t you just create a SwiftUI app like everyone else (-:

5 Likes

You sure that shouldnt be

 acl_free( accessList )

???

in C you have to pass it in by ref (the &) to SET it
but once its set you free IT not a reference (so no &)
I wonder if its the same in Swift ?

funny, Clever.
And 100% completely useless and unhelpful

1 Like

The explanation is in the post linked in the reply, about the perils of ampersand. Using & in Swift is not exactly how it works in C.

What is the purpose and context of that code?

I never thought of trying AI. I do wonder how it would fair if the answer was as hard to find as this one?

Quinn is awesome, I owe him so much beer at this point, that I’d end up buying him a brewery. There are literally many deep dark secrets in the macOS that I’d have never understood without his assistance, and once again I am being schooled by the macOS master.

I did try that, but Xcode complained about it and my GoogleFu let me down with the error messages. I tried a couple of things based on similar error messages (and guessing), but none would stop Xcode from whining, until I silenced it with the &. The Xojo code for this doesn’t use a byRef, I should have seen that as an indicator I’m on the wrong path.

Seems like it’s something that I need to learn next.

2 Likes

I missed this, sorry.

The code uses API to read the Access Control Lists from a file. Which overrule the standard POSIX permissions. So looking at the permissions, you can have complete control, but an ACL might prevent you from doing anything or something as simple as deleting the file.

As you can imagine, this has caused frustration since it became available on the macOS, especially as Apple provide no GUI for customers to see, edit or remove these.

In recent years, they’ve even started adding controlling permissions to the xattrs, which adds even more frustration to the mix.

My #1 downloaded application is “Permission Reset”, and I’m in the process of porting it to SwiftUI. Which is one hell of an experience, as I already know what API I need, but sometimes figuring out how to use it in Swift is frustrating.

I’ve already refactored it twice to make it work nicer with SwiftUI and I’m now going to moving more shit around to improve the animation of the app.