f.launch does not work under Catalina

  1. ‹ Older
  2. 7 weeks ago

    Christian S

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

    You can check OpenFile methods in NSWorkspaceMBS class.

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

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

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

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

  8. 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
  9. 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

  10. @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

  11. Christian S

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

    You an check CFBookmarkMBS module in MBS Xojo Plugins .

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

  13. 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?"

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

  15. Michel B

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

    One thing is for sure, now they won't be able to blame it on Jony Ives :D

  16. Emile S

    Jul 29 Europe (France, Strasbourg)

    Always blame the French… ;)

  17. Tim J

    Jul 29 Pre-Release Testers, Xojo Pro Dehydrating in AZ
    Edited 7 weeks ago

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

    and

    "Apps are not the OS, but touting actual OS changes is boring."

  18. Richard D

    Jul 31 Pre-Release Testers, Xojo Pro Europe (UK, London)

    strange, the launch work on catalina using 2019r1.1

  19. Michel B

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

    Depends the nature of what you launch. A document does. Not an app. But it should not be an issue in R2.

  20. Richard D

    Jul 31 Pre-Release Testers, Xojo Pro Europe (UK, London)

    @Michel B Depends the nature of what you launch. A document does. Not an app. But it should not be an issue in R2.

    i guess i was opening doc,xls, csv, pdf and images...

  21. Michel B

    Aug 1 Pre-Release Testers, Xojo Pro RubberViews.com

    @Richard D i guess i was opening doc,xls, csv, pdf and images...

    Right. That is not broken in 2019R1.1 compiled apps under Catalina.

or Sign Up to reply!