Hi,
I am totally lost and do not even know where to even begin to solve this:
I codesigned and sandboxed my app using AppWrapper Mini, but now when I run my app - it does not load any of the databases or EULA.txt etc!
My app reads and writes to Library/Application Support/Test Data/notes.db etc.
My app is being run from Applications/Richard Summers/Test/Test.app
The app runs fine, but the already created and used databases are NOT loaded.
My app creates new databases and entries, so it seems that my app is reading / writing to somewhere completely unknown to me (as opposed to the correct location Library/Application Support/Test Data/)?
When sandboxed, an app writes it’s data into the Library/Containers/com.company.appname. By default the SpecialFolder.appdata ( not sure about that name) does the job for you. When not sandboxed, it is located in Library/Application Support. When sandboxed, it is located in Librairy/Containers/.
Yoann,
I have just found the newly created folder containing all the newly created database files etc. in the Library / Containers folder - exactly as you just advised
I am now however still unsure as to what to do now?
Do I need to change all the paths in my project file to the directory where I found all the newly created database files etc?
[quote=124837:@Richard Summers]Yoann,
I have just found the newly created folder containing all the newly created database files etc. in the Library / Containers folder - exactly as you just advised
I am now however still unsure as to what to do now?
Do I need to change all the paths in my project file to the directory where I found all the newly created database files etc?[/quote]
Do not use literal paths, such as Library/Application Support/Test Data/notes.db. Replace all that by the correct folderitem construction :
[quote=124841:@Richard Summers]Michel - I do use the correct construction (or at least I think I do):
[/quote]
My concern was the reference to paths. If you have used the construction, then the resulting path is automatically switched to containers when you sandbox. You should not have to change anything.
Verify all your app to make sure you do not have some forgotten GetFolderItem somewhere …
So basically - there is no problem - I was simply looking in the location for an unsandboxed app - when instead, I need to be looking in the sandboxed location for files.
In other words, this path in my project file:
Dim fi As FolderItem = SpecialFolder.ApplicationData.Child("Test Data")
If Not fi.Exists Then fi.CreateAsFolder
fi = fi.Child("notes.db")
Translates (in a sandboxed app), to: Library / Containers / etc. etc. etc.
[quote=124848:@Richard Summers]Trying my hardest to understand this:
So basically - there is no problem - I was simply looking in the location for an unsandboxed app - when instead, I need to be looking in the sandboxed location for files.
In other words, this path in my project file:
Dim fi As FolderItem = SpecialFolder.ApplicationData.Child("Test Data")
If Not fi.Exists Then fi.CreateAsFolder
fi = fi.Child("notes.db")
Translates (in a sandboxed app), to: Library / Containers / etc. etc. etc.[/quote]
That’s right. If you have used folderitem constructs to copy your database to applicationsupport, it should be there.
[quote=124828:@Richard Summers]The app runs fine, but the already created and used databases are NOT loaded.
My app creates new databases and entries, so it seems that my app is reading / writing to somewhere completely unknown to me (as opposed to the correct location Library/Application Support/Test Data/)?[/quote]
You may want to put some system.debuglog messages in your app to verify it is looking for the database in the right place. Or, are you getting any error message when you try to use the database, or load EULA.txt ? You should.
No - my app works as expected, it just didn’t use the already existing databases and txt files, therefore I thought there was a problem reading / writing to my databases.
But if I have understood this correctly - this is expected behaviour because the actual file storage location changes depending on whether the app is sandboxed or not.
I copied my unsandboxed support files over to the new location for sandboxed apps - and all now seems to be ok.
Thank you so much everyone - I have now learnt something new
Btw, AppWrapper can generate the necessary scripts to code sign and sandbox your app also while you are debugging (just switch off timestamp in AppWrapper, which delays the process).