Search code examples
cocoaapplescriptapplescript-objc

How to access from AppleScript a bundled file within a Cocoa-AppleScript Application?


In AppleScript I'm used to call:

set audio_file to (path to me as string) & "Contents:Resources:Audio:Music.mp3"
display dialog "Path: " & (quoted form of POSIX path of audio_file)

I have now this code inside a Cocoa-AppleScript project in Xcode. It compiles well, but the script is not running at all. The dialog never shows.

Without the (path to me as string) it works, but without the path.


Solution

  • And the answer is that, in a Cocoa-AppleScript Application, the right sintaxis is NOT:

    (path to me as text)
    

    BUT:

    (path to current application as text)
    

    me is not valid as self-reference. The correct one is current application.

    Hope this helps others :)