f.launch does not work under Catalina

  1. 7 weeks ago

    Michel B

    Jul 27 Pre-Release Testers, Xojo Pro RubberViews.com
    Edited 7 weeks ago

    Sounds simple enough, right ?

    My update class uses f.launch to run the Mac Installer .pkg file, but under Catalina, it simply won't work.

    I will have to scour MBS documentation to find the equivalent, and hope it works...

    Christian, which plugin can execute another app ?

  2. Beatrix W

    Jul 27 Pre-Release Testers, Third Party Store Europe (Germany)

    f.Launch works fine for me. Which file are you trying to launch?

  3. Michel B

    Jul 27 Pre-Release Testers, Xojo Pro RubberViews.com
    Edited 7 weeks ago

    I am trying to launch an installer pkg file.

    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.

  4. Beatrix W

    Jul 27 Pre-Release Testers, Third Party Store Europe (Germany)

    That's odd. At the end of my own self-written installer I launch the main app. That works fine even on Catalina.

    Some example code:

    dim f as FolderItem = getOpenfolderitem("")
    if f = Nil then Return
    f.Launch

    I selected a random app and it launched. What are you doing differently?

  5. Michel B

    Jul 27 Pre-Release Testers, Xojo Pro RubberViews.com
    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.

  6. Beatrix W

    Jul 27 Pre-Release Testers, Third Party Store Europe (Germany)

    That's a different problem. Specialfolder.Applications is nil. That doesn't crash for you in the first line?

  7. Sam R

    Jul 27 Pre-Release Testers, Xojo Pro, Third Party Store Hengchun, Pingtung, Taiwan

    add

    Dim i as integer = f.lastErrorCode
    if i <> 0 then Msgbox str( i )

    after f.launch

    If there's an error, it should give you the code.

  8. Christian S

    Jul 27 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    You can check OpenFile methods in NSWorkspaceMBS class.

  9. Michel B

    Jul 27 Pre-Release Testers, Xojo Pro RubberViews.com

    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.

  10. Michel B

    Jul 27 Pre-Release Testers, Xojo Pro RubberViews.com

    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)
      
  11. Sam R

    Jul 27 Pre-Release Testers, Xojo Pro, Third Party Store Hengchun, Pingtung, Taiwan
    Edited 7 weeks ago

    @Michel B Sam, thank you. I did what you suggested, and it reports 101.

    https://docs.xojo.com/FolderItem.LastErrorCode
    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.

  12. Michel B

    Jul 27 Pre-Release Testers, Xojo Pro RubberViews.com

    I have it on good authority that the issue I reported will most probably no longer present in the next version of Xojo.

    This thread may have alarmed unnecessarily. Sorry.

  13. Sam R

    Jul 27 Pre-Release Testers, Xojo Pro, Third Party Store Hengchun, Pingtung, Taiwan

    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).

  14. Sam R

    Jul 27 Pre-Release Testers, Xojo Pro, Third Party Store Hengchun, Pingtung, Taiwan

    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
  15. Kevin G

    Jul 27 Pre-Release Testers, Xojo Pro Gatesheed, England

    A scan of the Apple developer docs seems to indicate that you can still state a preferred app via LSOpenFromURLSpec.
    https://developer.apple.com/documentation/coreservices/1441986-lsopenfromurlspec

  16. @Michel B — 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

  17. Christian S

    Jul 28 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    You an check CFBookmarkMBS module in MBS Xojo Plugins .

  18. Jeff T

    Jul 28 Pre-Release Testers Midlands of England, Europe

    I suspect that Xojo is late (as usual) on moving to more up-to-date functions

    If Apple would just leave stuff alone for a while..

  19. Norman P

    Jul 28 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    I think their motto bas become "Have we broken this lately?"

  20. Not sure they have one motto only. So:
    Breaking is fun
    Break but don't tell (developers)
    Broken is beautiful

  21. Newer ›

or Sign Up to reply!