How to properly copy files to Application Scripts folder from Sandboxed App?

后端 未结 1 353
梦如初夏
梦如初夏 2021-01-27 05:13

I\'m really confused about how to properly copy files and grant permission to execute e.g. an AppleScript file from a sandboxed application. I\'ve read several articles and thre

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-27 05:37

    Well, it seems like I have found a solution which (at least for me) seems to be more or less user friendly and within Apple's sandbox guidelines.

    Again, I'm very new to app development using Xcode and SwiftUI so I'm not sure if this solution is 100% "the right way of doing it". But since it took me ages to find this out, maybe someone else can use it and speed up development!

    Solution

    Like I have mentioned in my question above, I was trying to get rid of the (in my opinion) pretty annoying NSOpenPanel Finder prompt, where the user is supposed to select the folder. I further asked about the Copy Files setting in the app's Build Phase tab - it turned out that this was the solution! Unfortunately, I still don't have any clue about the list of destination which are presented in the dropdown but choosing Absolute Path and inserting

    Users/$USER/Library/Application Scripts/$PRODUCT_BUNDLE_IDENTIFIER
    

    did the job! The file gets copied on every build into the app's Application Scripts directory, from which I can run scripts outside the sandbox.

    0 讨论(0)
提交回复
热议问题