【问题标题】:Which alternatives do I have to create an .app package for Mac?我必须使用哪些替代方法为 Mac 创建 .app 包?
【发布时间】:2011-08-31 17:03:12
【问题描述】:

我有一堆 shell 脚本和可执行文件,我想将它们打包到 Mac 的独立 .app 包中。我还需要向用户显示一个输入对话框,以便我可以获取一个值并将其用作我的一个 shell 脚本的输入。

我注意到 Automator 允许您创建独立的应用程序并将输入对话框添加到工作流,但我不清楚如何:

  • 在 .app 包中包含我的可执行文件
  • 在添加“运行 shell 脚本”操作时指定相对路径,以便在用户双击 .app 时执行我的可执行文件

另一方面,我找到了appify,它解释了如何将单个 bash 脚本转换为可点击的 .app。很好,但我仍然需要输入对话框位。

我必须使用哪些替代方法来创建具有上述要求的 .app 文件?

【问题讨论】:

    标签: macos automator


    【解决方案1】:

    您可以应用程序将其包装在一个 .app 包中,并让脚本本身使用 osascript 命令通过 AppleScript 显示输入对话框:

    ans="$(osascript -e 'Tell application "System Events" to activate' \
        -e 'Tell application "System Events" to display dialog "What?" default answer "Fugeddaboutit" buttons {"Yup", "Nope", "Cancel"} default button 1' \
        -e '(button returned of result) & ":" & (text returned of result)' 2>/dev/null)"
    
    if [[ $? -ne 0 ]]; then
        echo "You cancelled!"
    else
        echo "You entered '${ans#*:}', and pushed the ${ans%%:*} button."
    fi
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-16
      • 2017-09-22
      • 1970-01-01
      • 2016-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多