SpecialFolder.Applications points to /System/Applications in macOS Catalina?

I’m trying to get at the /Applications folder, but from what I’ve been able to deduce, SpecialFolder.Applications keeps returning the /System/Applications folder item. Am I interpreting this correctly? If so, what’s the solution?

Cheers.

-bill k

You’re on Catalina arent you ?
Applications may appear in its side bar as one dir but in reality it is 2 that are merged for that appearance

Try volume( 0 ).child( "Applications" ). If that doesn’t work, then you may want to consider reading both and creating a merged list until someone can figure out the correct API for getting the “unified” applications folder.

Thanks Sam. I had the same revelation, just was hoping that there was a more correct way to get to the folder. I’m assuming that this method will break on non-english systems.

I’ll be honest and say that I don’t know.

Assuming that the two folders share the same name, what about: volume( 0 ).child( specialfolder.Applications.name )?

f.name should be the same on all systems, only f.displayName is localized. But I may be wrong.

Correct.

This gets the /Applications in 10.14-, can you see what happens in Catalina?

Dim f As FolderItem = SpecialFolder.System.Parent.Child(“Applications”)

NSFIleManager looks like the right way to get the URL

Dunno what Xojo is using internally for it

https://developer.apple.com/documentation/foundation/nsfilemanager/1407693-urlfordirectory?language=objc

  • (NSURL *)URLForDirectory:(NSSearchPathDirectory)directory
    inDomain:(NSSearchPathDomainMask)domain
    appropriateForURL:(NSURL *)url
    create:(BOOL)shouldCreate
    error:(NSError * _Nullable *)error;

where
directory = NSAllApplicationsDirectory
inDomain = NSAllDomainsMask
appropriateForUrl - NIL
create = FALSE
error is a ptr to an error object the call can fill in

see

https://developer.apple.com/documentation/foundation/nssearchpathdirectory/nsallapplicationsdirectory?language=objc
https://developer.apple.com/documentation/foundation/nssearchpathdomainmask/nsalldomainsmask?language=objc

[quote=461988:@Carlo Rubini]Assuming that the two folders share the same name, what about: volume( 0 ).child( specialfolder.Applications.name )?

f.name should be the same on all systems, only f.displayName is localized. But I may be wrong.[/quote]

That seems to be the easiest way of doing this, and should work on all but the weirdest installations. Thanks. Hopefully the Xojo folks will implement something like Norman’s solution soon and get this resolved. Cheers.

What do you think is the difference between /Applications and /System/Applications?

It looks like “/System/Applications” is where all the default operating system applications reside, and “/Applications” is where all the user installed applications get placed. The Finder makes the two appear together seamlessly and I actually had no idea that they were separate until I ran into this issue.

William - that seems consistent with what I have read in various places

You might want to read this other Thread: SpecialFolder returns wrong path in 10.15
One link from there (read #1): https://medium.com/@hammen/significant-changes-in-macos-10-15-catalina-of-interest-to-mac-admins-fbc3865c055e

Again: read the linked Thread.
And have a look at this Post, which links to an example project that returns an Array of FolderItems with all possible Application Directories.
There is even a Feature Request for that, since a similar behavior (the OS has different “default Application directories”) on other BuildTargets…: <https://xojo.com/issue/57672>

Thanks for the link Jürg, that’s exactly what I was looking for. Interestingly I did do a search for this topic before I started this conversation, not sure where that thread got buried. +1 for your Feedback Case. Cheers.

I have moved the Example Project: macOS: App Directories to my bits and pieces for Xojo Developers.

The example shows how to find Applications by BundleID (the preferred way), by AppName (this will try to find it in all possible system defined application directories), and it allows to get an Array of Folders defined by Apple (see: NSSearchPathDirectory).

So you can easily get all Application directories (including the per-user one, if it exists).