MacOS – When using a third-party script library, I can no longer save an AppleScript file in Script Editor.app

applescripterrormacosthird-party

I have an AppleScript .scpt file that uses the Dialog Toolkit scripting library:

Dialog Toolkit is an ASObjC-based script library for showing enhanced dialogs.

The following line is at the top of the .scpt file:

use script "Dialog Toolkit" version "2.0"

The Dialog Toolkit file is in the correct location:

/Users/Me/Library/Script Libraries/Dialog Toolkit.scptd

However, when I try to save my .scpt file in Script Editor.app, I am given the following message:

The dialog reads:

The document “Untitled.scpt” could not be saved. C and Objective-C pointers cannot be saved in scripts.

Compiling the script will reset property values and may resolve this issue.

I don't know the meaning of "C and Objective-C pointers", so I don't understand the problem.

I can successfully run and compile the script. But, after I compile the script, I still cannot save the file; I still get the above error message.

If I copy the full code and paste it into a New Document in Script Editor, the error still persists.

If I remove all of the Dialog Toolkit code from my script, then I can save the .scpt file, without error. Hence, it seems that the issue has something to do with how Script Editor handles an external script library.


Also, I have noticed general "bugginess" when working on my script that contains Dialog Toolkit code in Script Editor.

  • For example, sometimes Script Editor.app will spontaneously quit if the document is open.

  • Other times, when I press the "Compile the Script" or "Run the Script" button, my cursor transforms into the spinning pinwheel, and remains as a pinwheel for over a minute. Script Editor freezes up, so I then have to Force Quit Script Editor.


There is some chance that this question is related to a previous question of mine:

Everything that is listed in the "What I've tried:" section of the above question also failed to fix the The document could not be saved. error.


OS X El Capitan, version 10.11.6.

Script Editor Version 2.8.1 (183.1)

Best Answer

First thing I would try is opening up the scripteditor.app library panel. In Scripteditor go to menu item "Window/Library"

enter image description here

If dialog toolkit is present in the list, I would select it in the list and remove it. Then I would quit scripteditor.app and relaunch it again. Once scripteditor.app is up and running again, Open the Library panel and click on the “Add” button in the menu bar and navigate to ~/Library/Script Libraries and select Dialog Toolkit.scptd.

That will probably solve your problem. I have a funny feeling the problem is occurring because your new com.apple.ScriptEditor2.plist file probably does not contain any reference to the Dialog Toolkit.scptd as per this example in this image..

This is com.apple.ScriptEditor2.plist file opened in xcode

enter image description here