Applescript 指示在应用程序内部尝试调用时未找到资源

Applescript indicates resource not found when trying to call within inside the app

使用 AppleScript 当我尝试从 Scripts 文件夹中调用另一个 AppleScript 时,我对自己做错了什么感到困惑。我当前的脚本保存为 foo.app,我从 Bundle Contents 中看到了结构,但是当我尝试从 Scripts 文件夹中调用 bar.app 时,我得到一个对话框 Resource not found.

引用“How to access from AppleScript a bundled file within a Cocoa-AppleScript Application?”后我尝试了:

tell application "Finder"
    set thisFolder to (container of (path to me)) as string
    set insideApp to thisFolder & (path to resource "bar.app")
end tell

当出现错误时,我做了更多搜索,我引用了“How do I get the Scripts folder in the application bundle?”并尝试了:

tell application "Finder"
    set thisFolder to (container of (path to me)) as string
    set insideApp to (thisFolder as alias) & (path to resource "bar.app" in directory "Scripts")
end tell

定位 description.rtfd 我显示变量 thisFolder 和我得到的对话框 Macintosh HD:Users:darth_vader:Desktop: 但是当我 运行:

tell application "Finder"
    set thisFolder to (container of (path to me)) as string
    display dialog thisFolder
    set insideApp to thisFolder & (path to resource "Contents:Resources:description.rtfd")
end tell

我究竟做错了什么以及如何从 Scripts 文件夹中调用?

有一个普遍的误解:

path to me 指向脚本(包)的路径。
container of (path to me) 指向脚本(包)的封闭文件夹的路径

所以是:

set insideApp to path to resource "bar.app"

或:

set insideApp to path to resource "bar.app" in directory "Scripts"

或(最好)

set insideApp to alias ((path to me as text) & "Contents:Resources:description.rtfd")

根本不需要Finder