Can anyone suggest a way to Use Library in a .scpt/.scptd being run from an enclosing bundle/app? Ive tried putting it in either bundles script libraries but still its not found for some reason when I test.
Example: App with Use Library “Test” run script somescript.scpt/somescript.scptd with Use Library “Test”
It will only run if I put the “Test” library into ~/Library/Script Libraries not if I put in SomeApp.app/Contents/Resources/Script Libraries
I’m not sure I understand what you’re doing, but it sounds like you need it in both places: the Script Libraries folder of the app, and the Script Libraries folder of the .scptd you are running via run script.
I guess I was thinking there would be a way to manually specify the library location either by a URL or in the plist. I have an app with scripts/script libraries in them and use dialog toolkit and some other libraries i have made in them. In the scripts folder, I have scripts called by the app using the libraries. Would like to simplify things when I export the main app to run only. The scptd’s dont save out as run only and having libraries in both places makes it a bit harder to maintain version updates. I would prefer they were just .scpt instead and all used the same libraries as the app.
You can specify another folder in an
Info.plist file, but it has to be a hard path — no ~ or anything.
The other thing that might work is using symlinks.
Probably I’m not understanding exactly what you’re trying to do, but perhaps you could have the main script use “defaults write” to write a path to its plist, and have the other scripts use “defaults read” to find whatever that path might be?
Thanks for all of the responses. I was looking to only have one library for all scripts in a bundle located in scripts so that I didnt have to save them as bundles themselves. It worked specifying paths for libraries with handlers.
set resourceLoc to POSIX path of (((path to me) as string) & "Contents:Resources:")
tell application "System Events" to set resourceLocation to POSIX path of (container of container of container of container of folder resourceLoc)
set scriptLocation to resourceLocation & "/Scripts"
However I couldn’t resolve a way to specify it for liraries speciying their own terminlogy such as Shanes Dialog Toolkit Plus.
I was looking to do this for the main reason of exporting a bundle run does not make .scptd files run only. Having to export seperately, remove the originals and add the run only files is a time consuming step that can quickly mess things up if you accidentally replace the original with run only.