You can check OpenFile methods in NSWorkspaceMBS class.
Thank you Christian. I am going to try.
Beatrix, I checked,
Specialfolder.Applications is not nil.
Sam, thank you. I did what you suggested, and it reports 101.
I tried to locate error codes in the LR, but nothing conclusive. At any rate I am going to try MBS and report.
Alright. I have to sadly report that NSWorkspaceMBS does not provide the solution.
Not only the code below works on High Sierra but does nothing under Catalina, but I could not find anything in Console to explain why.
At this point I have to conclude that for some reason, Apple must have tighten security in such a way that it is not possible anymore to launch an application from another.
The only solution I have is to test the system version, and if under Catalina, instruct the user to run the pkg himself
dim f as FolderItem = SpecialFolder.Applications if f = nil then msgbox (f.ShellPath +" is nil") f = f.Child("App Store.app") if f = nil then msgbox( f.ShellPath +" is nil") if f <> nil and f.exists then dim w as new NSWorkspaceMBS dim file as FolderItem = SpecialFolder.Applications.Child("App Store.app") dim error as NSErrorMBS dim configuration as new Dictionary dim options as Integer // today we start 64 bit version configuration.Value(w.NSWorkspaceLaunchConfigurationArchitecture) = w.NSBundleExecutableArchitectureX86_64 // and hide all others options = w.NSWorkspaceLaunchDefault dim r as NSRunningApplicationMBS = w.launchApplicationAtFile(file, options, configuration, error)
@Michel B Sam, thank you. I did what you suggested, and it reports 101.
101 FileNotFound The File was not found.
There's still a lot broken in Catalina right now; I see others in the industry are getting concerned two months may not be enough time to fix all the problems.
Just want to add for anyone else looking at this; all NSWorkspace API for launching apps has now been deprecated. It appears that we as developers are no longer allowed to launch other applications on a users system. I presume this is for security purposes <facePalm/>. Same as the function for zipping/unzipping files.
However [[NSWorkspace sharedWorkspace] openURL:] is still there, so you can ask for a file to be opened, and the OS will open it in whatever application is see's fit. Just no longer can you specify which application to open the file (which is dumb as I often do this, so that the file is going to open in the application that I expect to, rather than some scammy app that's commandeered the filetype).
If anyone needs this prior to the launch of the aforementioned Xojo update. Please note that as the API returns a boolean, so does this function.
Public Function launchItem(inFile as folderItem) as boolean #if targetMacOS then // --- Patch to open a Xojo folderitem using [[NSWorkspace sharedWorkspace] openURL:] // July 28th 2019 - Sam Rowlands declare function NSClassFromString lib "Foundation" ( inNSClassName as CFStringRef ) as integer declare Function NSURLfileURLWithPathIsDirectory lib "AppKit" selector "fileURLWithPath:isDirectory:" _ (NSURLClass as integer, path as CFStringRef, directory as boolean) as integer declare function NSWorkspaceSharedWorkspace lib "AppKit" selector "sharedWorkspace" ( NSWorkspaceClass as integer ) as integer declare Function NSWorkspaceOpenURL lib "AppKit" selector "openURL:" ( NSWorkspaceSharedInstance as integer, inNSURL as integer ) as boolean return NSWorkspaceOpenURL( NSWorkspaceSharedWorkspace( NSClassFromString( "NSWorkspace" ) ), _ NSURLfileURLWithPathIsDirectory( NSClassFromString( "NSURL" ), inFile.nativePath, inFile.directory ) ) #endif End Function
A scan of the Apple developer docs seems to indicate that you can still state a preferred app via LSOpenFromURLSpec.
I have see this where the launch fails and then executing the same code again works. 19r1.1 and 10.15b4.
As for mottos, don't forget -
"Change for the sake of change."
"Apps are not the OS, but touting actual OS changes is boring."