Answering my own question, after some hours of research and experimentation (with thanks to various posts on macscripter.net and autodidaktos.com):
Add the script file, e.g., yourScriptFile.sh, to the project via the menu File - Add Files to (yourProject)...
Include the script file in the app bundle so that it will be included with the app when distributed:
- In the Project Navigator or the Jump Bar select your project
- Select the "Build Phases" tab
- Expand the "Copy Bundle Resources" section (this applies to Xcode 4.6.3, maybe different with other versions)
- Add an item to the Bundle Resources by clicking the "+" button at the bottom of the list
- Select the script file to add to the bundle, e.g., yourScriptFile.sh
In your AppleScriptObjC script, add the following subroutine
on applicationWillFinishLaunching_(aNotification) set pathToResources to (current application's class "NSBundle"'s mainBundle()'s resourcePath()) as string end applicationWillFinishLaunching_
Also in your AppleScriptObjC script, add the following where appropriate:
property pathToResources : "NSString" -- works if added before script command
Where appropriate, also add the following in your AppleScriptObjC script:
set yourScript to pathToResources & "/yourScriptFile.sh" -- gives the complete unix path -- if needed, you can convert this to the Apple style path: set yourScriptPath to (((yourScript as text) as POSIX file) as alias)`
As an aside, you could then open the file for read using
tell application "Finder" open yourScriptPath end tell
It should then be possible to execute the script or copy it to somewhere for user access using the do shell script
construction. It should also be possible to execute the script directly from the bundle if appropriate.