Hi, I am trying to load files from the Apple Vision Pro's storage into a Unity App (using Apple visionOS XR Plugin and not PolySpatial package). So far, I've tried using UnitySimpleFileBrowser and UnityStandaloneFileBrowser (both aren't made for the Vision Pro and don't work there), and then implemented my own naive file browser that at least allows me to view directories (that I can see from the App Sandbox). This is of course very limited:
Gray folders can't be accessed, the only 3 available ones don't contain anything where a user would put files through the "Files" app.
I know that an app can request access to these "Files & Folders":
So my question is: Is there a way to request this access for a Unity-built app at the moment? If yes, what do I need to do? I've looked into the generated Xcode project's "Capabilities", but did not find anything related to file access. Any help is appreciated!
Hi, I am trying to load files from the Apple Vision Pro's storage into a Unity App (using Apple visionOS XR Plugin and not PolySpatial package).
So, my immediate question here is what your larger "goal" here actually is? visionOS generally uses the same file access model as iOS, which means apps get access to files through one of two broad mechanisms:
-
The files are added to one of the app’s container directories. There are many different APIs that use the broad "flow", but the simplest case is having your app appear in File.app so that the user can directly add files. Basic access can be enabled by setting UIFileSharingEnabled and (possibly) LSSupportsOpeningDocumentsInPlace.
-
The app uses an API like UIDocumentPickerViewController to allow the user to give their app access to specific files or directories.
Finally, apps that are built around "documents" generally use the approach described in "Building a document browser-based app", which actually provides a unified interface for both of the two approaches above.
Finally, commenting on this approach:
I then implemented my own naive file browser that at least allows me to view directories (that I can see from the App Sandbox).
This won't work. The primary goal of the App Sandbox is to protect "user data", which is exactly the kind of data you want access to. All the directories you are able to directly access like that are directories that were intentionally left "open" by the App Sandbox, generally because it made our framework easier to implement AND the contents were not considered "sensitive". If you experiment a bit further with your file browser, I believe what you'll find is:
-
Your app is only able to read some of the data it can see and can't really write anywhere it can see.
-
The user doesn't really have any good way to easily modify any of the areas you can "see".
Both of those points are intentional, as you're actually looking at the private details of our own implementation, not the "useful" file system.
All of that is what actually leads to #2 above. The system handles the interface used to select files*, then "hands" your app access to that object through the URL it returns to your app. This ensures that your app only has access to files the user specifically gave you access to.
*Note that bookmark files can be used to preserve file access using the process described in "Persist file access with security-scoped URL bookmarks".
I know that an app can request access to these "Files & Folders":
I don't have a VisionPro at hand to double-check this, so I'm not sure what actually shows up in the interface. However, the flow I've outlined above is actually how sandboxed macOS apps (which have the broadest level of file access), are expected to behave, so my general answer won't really change.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware