UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Access outside of Sandbox

Forums > Swift

Hi,

While developing my app I've created a File Dialog to allow me to load and save files (it works, hurrah!) and while developing it, it has always stayed within the sandbox, ie, never let me go above the current app's 'Document' folder.

However, I've moved the code over to another app, the main project I developed it for, and when clicking the 'Parent Folder' button, it allows me to travel up through the folder structure until I reach '..' with the folders 'Library', 'System', 'Users' and 'Applications' beneath it. I am able to save my files in any of the folders throughout the structure (though any other files there aren't presented).

Firstly, should I be able to do that? Secondly, if so, how the hell have I done it? And thirdly, why would it be exhibiting such behaviour in the this app when it didn't in the original code? I've got a feeling it's against the guidelines so I'd really like to know how to resolve it.

Any thoughts?

Thanks in advance,

Jes

3      

Assuming you are talking about a Mac app, I can think of two reasons where someone would be able to access files outside the Sandbox in the main project.

  • The project turned off the Sandbox.
  • The Sandbox settings give the app permission to access user selected files.

It's OK for a document-based Mac app to let people save documents where they want. I would be annoyed if a Mac app forced me to save my documents in the app's Documents folder.

4      

Hi,

I've tried again today and haven't been able to replicate. It was, however, running in the simulator for an iPad..! There is a suspicion that maybe I'd run it in the mac simulator beforehand but I can't be sure; I'll keep checking.

Thanks for the response :)

3      

I am designed to operate within a safe and restricted environment, known as the "sandbox." This means I can't browse the internet or access any information or content that has been generated or updated after my last update in September 2021.

My primary function is to assist and provide information based on the data available up to that point. If you have any questions or need help with anything within that scope, feel free to ask, and I'll do my best to assist you!

3      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.