Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么不是';我的Swift应用程序无法编写脚本?_Swift_Macos_Scriptable - Fatal编程技术网

为什么不是';我的Swift应用程序无法编写脚本?

为什么不是';我的Swift应用程序无法编写脚本?,swift,macos,scriptable,Swift,Macos,Scriptable,我正在尝试制作一个快速的应用程序,'Earwig.app',MacOS,可编写脚本。首先,我无耻地从中窃取了一个示例,添加了两个文件,一个.sdef和一个.swift,如下所示。我已在info.plist中设置了可脚本和脚本定义文件名 我的申请书是: tell application "EarwigServer" to save in "path/to/file" 运行脚本时出现错误,“EarwigServer出错:无法继续保存。” 在这一点上,我被卡住了。有什么建议吗 sdef文件: <

我正在尝试制作一个快速的应用程序,'Earwig.app',MacOS,可编写脚本。首先,我无耻地从中窃取了一个示例,添加了两个文件,一个.sdef和一个.swift,如下所示。我已在info.plist中设置了可脚本和脚本定义文件名

我的申请书是:

tell application "EarwigServer" to save in "path/to/file"
运行脚本时出现错误,“EarwigServer出错:无法继续保存。”

在这一点上,我被卡住了。有什么建议吗

sdef文件:

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

<dictionary title="ScriptableSwift Terminology">

    <suite name="ScriptableSwift Scripting Suite" code="SSss" description="Standard suite for application communication.">

        <command name="save" code="SSssSave" description="Save something.">
            <cocoa class="ScriptableSwift.SaveScriptCommand"/>
            <parameter name="in" code="Fpat" type="text" description="The file path in which to save the document.">
                <cocoa key="FilePath"/>
            </parameter>
            <result type="text" description="Echoes back the filepath supplied."/>
        </command>

    </suite>
</dictionary>
info.plist:


当我将
ScriptableSwift.SaveScriptCommand
更改为
EarwigServer.SaveScriptCommand
时,它开始工作。这似乎很明显,我知道,但我以前做过,但没有效果。在我清理构建文件夹之前,更改似乎不会生效

此xml有效,swift文件保持不变:

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

<dictionary title="EarwigServer Terminology">

    <suite name="EarwigServer Scripting Suite" code="ESss" description="Standard suite for application communication.">

        <command name="run" code="ESssErun" description="Save something.">
            <cocoa class="EarwigServer.SaveScriptCommand"/>

            <parameter name="in" code="Fpat" type="text" description="The file path in which to save the document.">
                <cocoa key="FilePath"/>
            </parameter>
            <result type="text" description="Echoes back the filepath supplied."/>
        </command>

    </suite>
</dictionary>


感谢您的输入

它无法工作的原因很多。麻烦的是,任何微小的错误都会破坏整个功能。例如,您是否在Info.plist中添加了所需的键和值?我很确定我的Info.plist是正确的,但我已经用添加的屏幕抓图编辑了这篇文章。我刚刚添加了一个示例项目中的两个文件,该项目旨在根据需要调整它们。我想知道我是否把类名ScriptableSwift.SaveScriptCommand搞错了。我已经尝试了很多排列,但都没有成功。此外,sdef文件中的XML对语法非常敏感,而在脚本编辑器中运行脚本时,它对反馈错误却毫无帮助。我在第一行的XML标记之前引入了一个选项卡,花了一段时间才找到它。在osascript中运行脚本在文件中报告了错误,而在脚本编辑器中运行脚本只返回了一个模糊的错误。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">

<dictionary title="EarwigServer Terminology">

    <suite name="EarwigServer Scripting Suite" code="ESss" description="Standard suite for application communication.">

        <command name="run" code="ESssErun" description="Save something.">
            <cocoa class="EarwigServer.SaveScriptCommand"/>

            <parameter name="in" code="Fpat" type="text" description="The file path in which to save the document.">
                <cocoa key="FilePath"/>
            </parameter>
            <result type="text" description="Echoes back the filepath supplied."/>
        </command>

    </suite>
</dictionary>