AppleScript responses no longer work

I have an app in the Mac App Store, currently in its version 3. I now have to update it to version 4, with quite a lot of new features, but a lot has changed in macOS environment in the 3 years since my last update.

In particular the app does 3 types of scripting (it has its part in observatory automation for astronomy).

Firstly it send AppleScripts to a macOS application, from a different developer, to control an all-sky camera. That no longer works because this application is even older than mine and doesn’t support access-groups, which are now needed for sandboxed apps. I’m in contact with the developer to solve that.

Secondly, it sends JavaScripts to another large application (which controls telescopes etc, and which as a cross-platform application, does not use AppleScript) to take action in various circumstances. This continues to work fine.

Finally, it supports a small number of AppleScript commands to report various measurements. This is for the benefit of another third-party app which can use them. This no longer works, and is the problem which is exercising me at the moment.

There seem to be 4 elements I need to readjust.
1.The HandleAppleEvent handler in the App, which until now I’ve not changed since the last working version 3;
2. the sdef file, which is very simple and only has one suite with my commands in it (no Standard Suite etc.);
3. the info.plist file, which has The NSAppleEventsUsageDescription string set, the Scriptable flag set and the Scripting definition file name set
4. the entitlements;,where I have the …scripting-targets entitlement set for my outgoing scripts, but nothing for incoming.

Has anybody any advice on things I have missed?

Thanks,
Richard

I forgot to mention: if I look at the dictionary in Script Editor I find 3 suites: Standard Suite, Text Suite and Type Definitions. I haven’t defined any of these but they are fully populated with items which have no connection in my code, so none of them work. There commands I define in my own suite are nowhere to be seen.

The next thing I discovered: there are a few Apple apps (e.g. Preview) which do not have an sdef file at in the Resources folder. They have the same behaviour with Script Editor (i.e. the same 3 suites appear).

Like my app, they show “Scriptable” as Yes in the Info.plist, but, unlike mine, do not identify a “Scripting definition file name”.

So maybe my sdef file is being internally rejected, maybe because it has something wrong in its structure (though it used to work).

I’m not sure what’s going on here.

An application does not need a sdef file to be scriptable - they can instead report their sdef data in response to a system inquiry. This is how apps that include plugins integrate the plugin’s scriptable components into their dictionary. Perhaps this is how the Apple apps are working.

I’m equally in the dark. I didn’t look hard but found 2 apps (up to the letter P !), Preview and Igor Pro (which is non-Apple) which have the behaviour I mentioned. The thing is, they may well use another mechanism to report sdef data, but they end up with the same dictionary as my app in the Script Editor. Think I’ll post my sdef file (in the next post) to see if there’s anything obviously wrong with it.

Here’s my sdef file. I know it’s incomplete in that it doesn’t mention any Standard suite etc., but it worked up to v3 of my app. The point is: is there anything “wrong”, rather than, “could be improved”

Thanks,
Richard

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">

<dictionary title="CloudWatcher Terminology">
    
    <suite name="CloudWatcher Suite" code="CWch" description="Cloudwatcher-specific classes and commands">
        
        <access-group identifier="com.ClearAndDark.CloudWatcher.readings"/>
    
		<command name="SQM" code="CWchSQMv" description="Gets the SQM value">
			<result description="SQM value in magnitudes per square arcsecond">
            <type="real"/>
		</command>
  
		<command name="SkyIRTemp" code="CWchSIRt" description="Gets the Sky IR Temperature">
			<result description="Sky IR Temperature in the units specified in the CloudWatcher app">
            <type="real"/>
		</command>

		<command name="SkyConditions" code="CWchCldC" description="Gets the sky cloud conditions">
			<result description="One-word description of sky cloud conditions based on the IR temperature">
            <type="text"/>

		</command>
		<command name="AmbientTemp" code="CWchAmbT" description="Gets the Ambient Temperature">
			<result description="Ambient Temperature from the sensor specified in the CloudWatcher app" type="real"/>
		</command>
		<command name="Windspeed" code="CWchWind" description="Gets the windspeed">
			<result description="Windspeed in the units specified in the CloudWatcher app" type="real"/>
		</command>
		<command name="RelHum" code="CWchReHu" description="Gets the Relative Humidity">
			<result description="Relative Humidity measured in percent" type="real"/>
		</command>
		<command name="DewPoint" code="CWchDewP" description="Gets the Dew Point">
			<result description="Dew Point measured in the units specified in the CloudWatcher app" type="real"/>
		</command>
	</suite>
</dictionary>

OK, I spotted one, thanks to the format highlighting here which is a bit more obvious than in Xcode. I changed the format of the first 3 commands recently and missed a slash character. I’ve changed it now (see below) but it made no difference.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">

<dictionary title="CloudWatcher Terminology">
    
    <suite name="CloudWatcher Suite" code="CWch" description="Cloudwatcher-specific classes and commands">
        
        <access-group identifier="com.ClearAndDark.CloudWatcher.readings"/>
    
		<command name="SQM" code="CWchSQMv" description="Gets the SQM value">
			<result description="SQM value in magnitudes per square arcsecond" type="real"/>
		</command>
  
		<command name="SkyIRTemp" code="CWchSIRt" description="Gets the Sky IR Temperature">
			<result description="Sky IR Temperature in the units specified in the CloudWatcher app" type="real"/>
		</command>

		<command name="SkyConditions" code="CWchCldC" description="Gets the sky cloud conditions">
			<result description="One-word description of sky cloud conditions based on the IR temperature" type="text"/>

		</command>
		<command name="AmbientTemp" code="CWchAmbT" description="Gets the Ambient Temperature">
			<result description="Ambient Temperature from the sensor specified in the CloudWatcher app" type="real"/>
		</command>
		<command name="Windspeed" code="CWchWind" description="Gets the windspeed">
			<result description="Windspeed in the units specified in the CloudWatcher app" type="real"/>
		</command>
		<command name="RelHum" code="CWchReHu" description="Gets the Relative Humidity">
			<result description="Relative Humidity measured in percent" type="real"/>
		</command>
		<command name="DewPoint" code="CWchDewP" description="Gets the Dew Point">
			<result description="Dew Point measured in the units specified in the CloudWatcher app" type="real"/>
		</command>
	</suite>
</dictionary>