But since I posted, I did other experiments trying to launch a regular app, and I get the same result.
No error, but nothing happens.
I am working with a small test app that simply opens the MAS app. Under High Sierra, it runs flawlessly, under Catalina Beta 19A512f, it simply does nothing.
I just tried to launch the app from a shell with Open, and get the same result. It works as expected under High Sierra, and does nothing under Catalina.
But your post made me wonder if there would be a difference between launching apps, and documents.
To test that, I tried to open a text file. I get a dialog
“test.app” would like to access files in your download folder.
[Don’t Allow] [OK]
When I click OK, the text file is opened just fine.
So indeed, launch works for documents, although apparently Apple’s paranoia has increased, and the user has to confirm access to the folder.
I am left with the same predicament. I tried to dive into Monkeybread’s documentation with a search, but frankly, it exceeds my comprehension.
dim f as FolderItem = SpecialFolder.Applications.Child("App Store.app")
if f <> nil and f.exists then
system.DebugLog("Trying to launch " + f.ShellPath)
f.launch
end if
BTW I tried to run 2019R1.1 under Catalina. After dancing in the dock for quite a while, it shows no window and seems to go into hiding like a service. I see it in Activity monitor, though.
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
[code]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)
[/code]
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 . 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.
[code]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 ) )
@Michel Bujardet Well functions using “Alias Records” (or FSRefs) do not seem to work on APFS volumes. I suspect that Xojo is late (as usual) on moving to more up-to-date functions