• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Mac OSX OSX and sandbox stuff

D

Dennis Lenz

Guest
Hi everyone,

i´ve managed to successfully compile my App to OSX. Now i´ve also managed to read from the app´s "Contents/Resources" folder as this is what "working_directory" does output me.

BUT!

How can i SAVE to this location? My app does read things but it doesn´t save/update anything inside the *.app folder. All this is a bit unclear. It says:


  • Mac OS - Storage will depend on whether the application is sandboxed or not (following Apples rules).

..but i get the feeling that it is always and only sandboxed? I thought the working directory would be something like "~/Application Support/MyAppName" - where i could load save and store things like my hearts desire.

But obivously i was wrong.

Can *please* anybody enlighten me on this topic? What about the sandbox problem?
(OSX 10.11 El Capitan, XCode 7, GM:S v1.9 EA)

THANKS!

EDIT: It looks like it actually does save things - which is great. Unfortunately i have no idea WHERE.
 
D

Dennis Lenz

Guest
So it does obviously store things in my text files. When i reload my application, the changes are remembered. Now comes the fun thing: The text files haven´t changed at all!

How come it does know the changes then? Where is that stuff stored? Obvioulsy it will read from a different location than from where it saves to.
 
Last edited by a moderator:
D

Dennis Lenz

Guest


As you can see, my App does work fine - but it doesnt find files in the Application support folder. (See screenshot).

When i manually copy the "KGM_BETA" folder with all its files into the App Package (Show Package Contents function) -> Contents/Resources - my App WILL find the folder.
But i dont want it to load/save from the App itself! What am i supposed to do? In the OSX Settings in Game Maker Studio i´ve setup everything what i think might be correct:



As stated above, the whole thing works on Windows (AppData/Local/KGM_BETA).

Please can anybody help me with that issue? I´m jumping out of the window otherwise ;-) Thanks!!
 
D

Dennis Lenz

Guest
Just checked, what "working_directory" returns on OSX (when launching compiled app): Its something like Appname/Contents/Resources... but i don´t want that. I definately need the user Application Support folder.
On windows that returns the AppData folder which is correct.

Anybody? I can´t be the only one that ever tried that?
 
D

Dennis Lenz

Guest
show_message(string(working_directory));
show_message(string(program_directory));

...both return the same on OSX?

EDIT: They don´t. Apologies :rolleyes: But still my problem remains.
 
Last edited by a moderator:
D

Dennis Lenz

Guest
if you are looking for the folder for user information you want to get the game_save_id https://docs.yoyogames.com/source/dadiospice/002_reference/miscellaneous/game_save_id.html this (on Windows, Mac, Linux) returns the directory that is used for the save area (i.e. the Sandbox)

Russell
Thanks so much! That should be the command / function i was looking for all the time! It returns a correct path.
Unfortunately i still can´t access that particular folder. I dont know what to do ... this is all crazy somehow :)

For testing purposes i did this: (OSX)

gLib_Pic_Dir = game_save_id+"pictures";
if (directory_exists(gLib_Pic_Dir))

... and so on. But - it tells me that the folder doesn´t exist. (But it does). Are there any sandbox things that i am not aware of? Or any OSX directory related things? Oh well...
 

rIKmAN

Member
Thanks so much! That should be the command / function i was looking for all the time! It returns a correct path.
Unfortunately i still can´t access that particular folder. I dont know what to do ... this is all crazy somehow :)

For testing purposes i did this: (OSX)

gLib_Pic_Dir = game_save_id+"pictures";
if (directory_exists(gLib_Pic_Dir))

... and so on. But - it tells me that the folder doesn´t exist. (But it does). Are there any sandbox things that i am not aware of? Or any OSX directory related things? Oh well...
Does "game_save_id" include a trailing slash at the end?
If not you need to add the slash yourself - ie. game_save_id + "/pictures";
It may even need a trailing slash - ie. game_save_id + "/pictures/";

Use show_message, show_debug_message or draw_text to print out 'gLib_Pic_Dir' after you have assigned it and see if it contains what you expect (a valid path)

Also I'm not 100% sure whether you need / or \ on a Mac so maybe play with those too.
 
D

Dennis Lenz

Guest
Yes, the path is valid (from what it outputs) nor is it an empty string. game_save_id outputs a slash at the end as well.

In my case its "/Users/sonicfire1980/Library/Application Support/KGM_BETA/".

The whole line looks currently like this:
gLib_Pic_Dir = scr_working_directory()+"library"+slash()+"pictures";

"scr_working_directory()" returns either working_directory (win) or game_save_id (osx) and "slash()" returns either "\" (win) or "/" (osx).

Screenshot:


As you can see, i´ve copied "KGM_BETA" (with library/pictures in it) to the application support folder. Still it doesn´t find files or folders... :-( Oh lord. That *must* be a sandbox-thing?

NOTE: The program running in the background has been compiled before (not just "green arrow" launch remotely).
 
Last edited by a moderator:
D

Dennis Lenz

Guest
Any ideas? I´ve read that OSX uses something like "Library/Containers/com.yourdomainname.yourappname" for sandboxed apps. However, since "game_save_id" returns a path to "...Application Support" i assume it is NOT running sandboxed?
Then why on earth does "directory_exists" return zero?

EDIT: I´ve now included my KGM_BETA contents (scripts, pictures) into GM:S Include section - now when i export the OSX APP these files are included in the final App. That´s great. When i launch KGM now it finds the files - i assume it reads them from the App itself.

Now the thing that baffles me:
It even stores settings / updates. When i reload my App the settings have been remembered.

But for gods sake i can´t find the location on my Mac WHERE that has been stored. Not in documents, not in any Library/Containers/KGM_BETA nor in Library/Application Support/KGM_BETA.

I must be missing something here? It basically works but the save location is not visible to me? And that is the only thing i NEED to know...
 
Last edited by a moderator:
D

Dennis Lenz

Guest
EDIT: It works. And it does store files in Users/myUserName/Library/Application Support/KGM_BETA. I had to show hidden files for it to work using:

Code:
defaults write com.apple.finder AppleShowAllFiles YES
"Library" in Users/myUserName was previouls hidden.
 
Last edited by a moderator:
Top