Slow Applescript on OSX10.11

Using Xojo 16.3
I have re-surrected an old applescript for iCal to work in Calendar
to create new events from my app.
Raw applescript takes about 4 seconds
Compiled from my app on OSX10.8.5 takes 4.5 seconds
Running the app on 10.11 it takes 35 - 45 seconds!
I does not make a difference whether I compile the app on 10.8 or 10.11

I haven’t seen a big difference in the OS versions for the speed of my dozens of AppleScripts. But I use the MBS plugin.

Post the AppleScript and then I can do some testing.

Don’t forget that the later OS X versions ‘feature’ more security than previous, and rumor has it that Inter-application communication is on the chopping block (i.e. to be deprecated).

I seem to recall that there is proper calendar API now, you might want to check the MBS plugin to see if they have any of the classes.

10.11 with an applescript I wrote 8 years ago works plenty fast
I even have it set a long list of attendees and emails etc and its very quick

Here is the code
This takes over a minute under 10.11vs 4 seconds under 10.8

[code]–on run {iCal, sDate, eDate, HeadLine, Notes, Loc, TypeOfAlarm, triggerTime, alarmSound, Dauer}

set calendarName to “Work”
set startDate to “24.12.2016 15:00”
set endDate to “24.12.2016 16:00”
set TheSummary to “Test 2”
set TheDescription to “dfdfdfdfdf”
set TheLocation to “zu Hause”
set alarmType to “Message with Sound”
set AlarmTime to “-45”
set Bell to “Glass”
set Montag to “false”

–set calendarName to iCal
–set theSummary to HeadLine
–set TheDescription to Notes
–set theLocation to Loc
–set startDate to sDate
–set endDate to eDate
–set alarmType to TypeOfAlarm
–set AlarmTime to triggerTime
–set Bell to alarmSound
–set Montag to Dauer

set startDate to date startDate
set endDate to date endDate

tell application “Calendar”
tell (first calendar whose name is calendarName)
make new event at end of events with properties {summary:TheSummary, start date:startDate, end date:endDate, description:TheDescription, location:TheLocation, allday event:Montag}
if alarmType is not “None” then
set theEvent to (last event where its summary = TheSummary)
tell theEvent
if alarmType = “Message” then
– Add a message alarm
make new display alarm at end of display alarms with properties {trigger interval:AlarmTime}
else if alarmType = “Message with sound” then
– Add a message with sound alarm
make new sound alarm at end of sound alarms with properties {trigger interval:AlarmTime, sound name:Bell}
end if
end tell
end if

end tell

end tell

–end run

There is quite a difference in speed between the script itself and running it from Xojo. The same occurs if I use MBS plugin. During execution Calendar becomes unresponsive.

I have seen such behavior before for Outlook 2011, which didn’t like to have 100.000 mails loaded. As soon as the lovely app started synching - and it did this all the time - my AppleScripts took a long time. But I have no clue what Calendar is doing here.

I encountered the same thing.
Is your application signed?
It seems that codesign is required.

Thank you all for your input.
Interesting that I am not the only one…

No, my app is in-house only, so I never bothered with code signing.
I am not even registered as an Apple Developer.

I am happy to supply more code if someone want to test with code signing

I simply added the script to my app and did a build, which includes signing. Doing the AppleScript in the built app is way faster than before but not as fast as with the naked AppleScript. 10 seconds or so here on my Hackintosh.

Thank you Beatrix for testing this.
Looks like I have to join the Developer programme and start learning about code signing…

I presume that the 10 seconds are with the compiled Xojo app?
10 seconds is not great, but at least 4 times faster.

Since the AppleScript is apparently much faster when run directly as opposed to within the project, it would probably be worth trying a shell to

osascript <scriptname>

The other potential advantage is that using a shell mode 1 would not freeze the UI of the app.

I work with more than 10 different Applescripts in my projects and all of them are with the same speed at 10.10, 10.11 or 10.12.

@Paulo Vargas: I have almost 100 AppleScripts in my main project (Filemaker, Mail, Outlook etc). Have you tried the script from Gerd? The speed difference is big.