AppleScript and Mojave

  1. 4 weeks ago

    Emile S

    Dec 20 Europe (France, Strasbourg)

    I do not have a build license for Xojo 2018r4, but I am curious to know how to use AppleScript (on Mojave).

    Is the info.plist below valid ?

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
    <plist version="1">
    <dict>
       <key>NSAppleEventsUsageDescription</key>
       <string>MyApp uses Applescript for its own purposes.</string>
    </dict>
    </plist>

    The data above was saved to a text file (named info.plist) and dragged into the Xojo Project’s Navigation pane. The project runs in the IDE, but this is the only thing I can say about that.

    A test report is welcome (Yes it works / No [change this or that…]) TIA.

  2. Jürg O

    Dec 20 Pre-Release Testers, Xojo Pro

    @Emile S how to use AppleScript (on Mojave)

    You can use AppleScript in the very same way as before.
    The AppleScript Example (Add two Integer value) in the Documentation runs just fine on macOS 10.14. No warnings, no user confirmation - it just works as expected, even in a Xojo 2018r4 built application running on macOS 10.14.

    With Script Editor: Compile and Save as Script with Filename: Add.scpt

    on run {value1, value2}
      return value1 + value2
    end run

    Drag the script in your Xojo Project. And in Xojo Code:

    Dim sum As String = Add(5, 10)

    The Restriction is: usage of AppleEvents (in an AppleScript)

    In order to use AppleEvents on newer versions of macOS (Mojave and later) you will need to include the NSAppleEventsUsageDescription key in your plist file.

    My guess is that AppleEvents are things like: tell application "iTunes" or tell application "Finder" in an AppleScript.
    But I'm not quite sure if that's correct (or if that is all that is restricted)... I'd appreciate an answer of someone how can clarify what AppleEvents are. Which "Actions", what "Code" in an AppleScript is considered an AppleEvent?
    Because we only need this additional Info.plist entry for using AppleEvents - not for a simple AppleScript.

  3. Robin L

    Dec 20 Xojo Inc Europe (Germany, Rehlingen)
    Edited 4 weeks ago

    "Since 2018r4 links against the macOS 10.4 SDK you need to update your application otherwise Applescripts will not function"

    References:
    http://docs.xojo.com/UserGuide:AppleScripts
    https://www.felix-schwarz.org/blog/2018/08/new-apple-event-apis-in-macos-mojave
    https://indiestack.com/2018/08/apple-events-usage-description/
    https://developer.apple.com/documentation/security/nsappleeventsusagedescription

    Lifted from a Feedback case :)

  4. Jürg O

    Dec 20 Pre-Release Testers, Xojo Pro

    @Robin L-Mitchell otherwise Applescripts will not function

    But that's not quite correct. A simple AppleScript will function just fine. See the example above.
    It would be good to clarify what is common and yet different in AppleScript and NSAppleEventsUsageDescription.

  5. Beatrix W

    Dec 20 Pre-Release Testers Europe (Germany)
    Edited 4 weeks ago

    AppleScript under Mojave work (more or less fine) without the NAAppleEvents... definition under Xojo 2018r3.

    An AppleEvent is a single atom of an AppleScript. For instance, I use a simple AppleEvent to start something in the main app from the helper app. The part with event below is the AppleEvent.

     ScriptText.Append "ignoring application responses"
      ScriptText.Append "«event MaxSarch»"
      ScriptText.Append "end ignoring"
      ScriptText.Append "end tell"

    To use AppleScripts under Mojave your app has to ask the OS if the Script is allowed for the SPECIFIC APP with https://www.monkeybreadsoftware.net/applescript-nsapplescriptmbs-shared-method.shtml#1

    I don't know how to do this in Xojo code only.

  6. Beatrix W

    Dec 20 Pre-Release Testers Europe (Germany)

    Did a test for Xojo 2018r4: you need both the function from the MBS plugin AND the plist entry.

    Soon, very soon we will have "please confirm that you are allowed to use the mouse".

  7. Greg O

    Dec 20 Xojo Inc

    @Jürg O But that's not quite correct. A simple AppleScript will function just fine. See the example above.
    It would be good to clarify what is common and yet different in AppleScript and NSAppleEventsUsageDescription.

    I think you’ll find that the restriction is enforced when your AppleScript targets other applications. Things like tell “Finder” or tell “System Preferences”.

  8. Emile S

    Dec 20 Europe (France, Strasbourg)

    @Robin L-Mitchell Lifted from a Feedback case :)

    The question comes from that Feedback ;(

  9. Beatrix W

    Dec 20 Pre-Release Testers Europe (Germany)

    @Emile Schwarz: did you read my post?

  10. @Beatrix W Soon, very soon we will have "please confirm that you are allowed to use the mouse".

    Please confirm that you are allowed to Use Move the mouse. ;)

  11. Daniel T

    Dec 20 Pre-Release Testers, Xojo Pro

    Please confirm that you are allowed to confirm that you want to confirm that you can use the mouse.

  12. Gavin S

    Dec 20 Pre-Release Testers, Xojo Pro UK
    Edited 4 weeks ago

    Security, please!

    -image-

  13. Emile S

    Dec 21 Europe (France, Strasbourg)

    @Beatrix W @Emile Schwarz: did you read my post?

    Yes, I do.

or Sign Up to reply!