Hi folks,
How does one go about prompting for access to protected directories in Catalina within a AppleScriptObjC app?
For example:
Hi folks,
How does one go about prompting for access to protected directories in Catalina within a AppleScriptObjC app?
For example:
You don’t – the system does it when you try to read something in one.
Thanks, Shane.
I’m not getting a prompt.
For my app, folks drag an item onto it… I then copy that item via ‘cp’
It’s this do shell ‘cp’ that’s getting operation not permitted, even moved to NSFileManager & no prompts.
My next test was to revert to an open file panel.
It sounds like you don’t have the relevant purpose string entry in your app’s Info.plist file. And don’t use cp.
Already added NSFileManager instead of cp… but the purpose string.
If I add sandbox to the apps capabilities then check of the options, still same error.
Got any examples here incase I’m holding it wrong?
You don’t want sandboxing. Do you have an entry for NSDesktopFolderUsageDescription/Privacy - Desktop Folder Usage Description in your Info.plist?
What’s the settings I should have in my entitlements or plait for
Shell accesss. (On 10.11)
I spend days trying to figure it out.
Googling etc.
When I turned sandboxing off it worked.
I had to turn sandboxing on to get access to my music folder
For ITLibrary framework use.
Can I just copy the entry from my entitlements file and place that in
My info.plist?
There’s no such entitlement. Using do shell script is just launching tasks. What you can do like that is still a bit fuzzy, and depends on the tool you use. Third-party tools should be notarized (apparently not a straight-forward thing to do to them).
If you’re sandboxed, I suspect you can’t do much with the shell – you won’t be able to pass security scoped URLs, which is how you get entitlements.
No.
Thanks. Yeah I’m
Not calling them from AppleScript but from a NSTask
It is a 3rd party python script.
I have found some stuff about notarizing them
I may try that.
The whole sandboxing thing is definitely pain in the but.
What are the downsides of turning it off?
I don’t plan to release my app in the store.
(Not Yet)
Thanks
Hi Shane,
I’ve added:
[format] NSDesktopFolderUsageDescription
Needed for pkgcreator to copy items form you Desktop[/format]
Still no prompt, I can read files on the Desktop but not copy.
CP or NSFileManager’s copyItemAtPath are failing.
This is an app which the item is dragged into, so I think i’ll need to try prompting for the file: https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/PromptforaFileorFolder.html
Getting in the app Store is the only thing I know you need it for.
Then use the URL you get, not paths. So copyItemAtURL:, not copyItemAtPath:.
No difference.
I’m using the following for the drag and drop, if makes any difference: https://macscripter.net/viewtopic.php?pid=165338#p165338
Ok, so in a new project this works:
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
set theDocument to choose file with prompt "Please select a document to process:"
log theDocument
set posixDocument to POSIX path of theDocument
log posixDocument
do shell script "cp " & quoted form of posixDocument & " ~/Downloads/file2.jpg"
end applicationWillFinishLaunching_
So… maybe something with this: https://macscripter.net/viewtopic.php?pid=165338#p165338