4

Swift アプリ、「Earwig.app」、MacOS、スクリプト可能にしようとしています。Making Cocoa Application Scriptable Swiftから恥知らずに例を盗み、以下に示すように .sdef と .swift の 2 つのファイルを追加することから始めました。info.plist に Scriptable および Scripting Definition filename を設定しました

私のAppleScriptは次のとおりです。

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>

迅速なファイル:

import Foundation
import Cocoa

class SaveScriptCommand: NSScriptCommand {
    override func performDefaultImplementation() -> Any? {
        print( "in" )
        let filePath = self.evaluatedArguments!["FilePath"] as! String

        print( "here" )
        return filePath
    }
}

info.plist:

info.plist

4

1 に答える 1