For those of us working on Mac titles, and in particular those wanting to produce universal binaries at the end of it, the use of IncBin is not exactly ideal. The reason for this is that when you then come to create your universal binary you end up with your media being included twice! Not good, as this turns a 16MB app into a 32MB one, which should just be around the 18MB mark. So, you can either have all this data stored externally, which is messy, or you can put the data into the application bundle itself, where both the PPC and Intel binaries can access the same data.
This is actually quite easy to do, so a lot of you may already have figured it out. But for those who haven't, this is how you go about doing it.
NOTE: I only do this for static game data, i.e. media and other files that I only need to read. Anything that needs to be written to I store in the "/Users/Shared/" folder. You should be able to write to the application bundle as well, although I haven't tested it, and it's generally not recommended.
1. If you haven't already built your app, go ahead and build one. There's no need to worry about making any code changes at this stage.
2. Now go to your application, right-click on it, and select "Show package contents".
3. A window will pop-up that will just show a folder called "Contents". Open this folder.
4. Now you will see two folders ("MacOS" and "Resources"). Open the "Resources" folder. By default, the only thing in here is your app's icon file.
5. Create a new folder and call it "Data" (or anything of your choosing).
6. Copy all of your game's media and other files into this new "Data" folder.
7. Highlight the "Data" folder and press Command+I (or right-click and select "Show info").
8. At the bottom of this dialogue box you will notice that the file permissions say "read and write" for you. Click on the drop-down arrow to reveal the permissions for the other types of user. You'll notice that these say "No access", which is obviously no good if you want your app to run from other accounts. Simply select each type of user and change the permissions to "read only"
9. With the above dialogue still open, click on the "Apply to sub-folders" button. You will be asked for confirmation and to then enter your admin password.
10. If you want to attempt writing to some files/folders, highlight each of the relevant files and/or folders and change the permissions to "read and write".
You may now close the application bundle's window, as you've now got all your data in place. The best bit is you don't need to do all of this again the next time you build your app as it isn't overwritten.
NOTE: If you later need to change any of the files that you have in the bundle, first change the original files and then copy them back into the bundle. You WILL need to change the permissions for any new files for the other users once you've copied the updated files into the bundle.
Now all you need to do is make some small changes to your code in order to load the data from the bundle instead of an external folder. This basically just means finding the correct path for the data.
1. First you need to find the filename of your app, as you can't assume the end-user won't have changed it. The following will do just that.
2. Next all you need to do is add the path to the data.
3. Now just add the data path to the beginning of all your loading functions, for example...
If you're making your app for more than one OS then you may need to have different loading sections between the compiler directives ?macos, ?win32, ?linux, etc.
And that's it. Just remember to change the permissions again for any files you later update and there's no need to re-copy data for every rebuild of your app. The only things that get overwritten when an app is built are the binary in the "MacOS" folder and the icon in the "Resources" folder.
For information on creating universal binaries and changing the icon, check here.
This is actually quite easy to do, so a lot of you may already have figured it out. But for those who haven't, this is how you go about doing it.
NOTE: I only do this for static game data, i.e. media and other files that I only need to read. Anything that needs to be written to I store in the "/Users/Shared/" folder. You should be able to write to the application bundle as well, although I haven't tested it, and it's generally not recommended.
1. If you haven't already built your app, go ahead and build one. There's no need to worry about making any code changes at this stage.
2. Now go to your application, right-click on it, and select "Show package contents".
3. A window will pop-up that will just show a folder called "Contents". Open this folder.
4. Now you will see two folders ("MacOS" and "Resources"). Open the "Resources" folder. By default, the only thing in here is your app's icon file.
5. Create a new folder and call it "Data" (or anything of your choosing).
6. Copy all of your game's media and other files into this new "Data" folder.
7. Highlight the "Data" folder and press Command+I (or right-click and select "Show info").
8. At the bottom of this dialogue box you will notice that the file permissions say "read and write" for you. Click on the drop-down arrow to reveal the permissions for the other types of user. You'll notice that these say "No access", which is obviously no good if you want your app to run from other accounts. Simply select each type of user and change the permissions to "read only"
9. With the above dialogue still open, click on the "Apply to sub-folders" button. You will be asked for confirmation and to then enter your admin password.
10. If you want to attempt writing to some files/folders, highlight each of the relevant files and/or folders and change the permissions to "read and write".
You may now close the application bundle's window, as you've now got all your data in place. The best bit is you don't need to do all of this again the next time you build your app as it isn't overwritten.
NOTE: If you later need to change any of the files that you have in the bundle, first change the original files and then copy them back into the bundle. You WILL need to change the permissions for any new files for the other users once you've copied the updated files into the bundle.
Now all you need to do is make some small changes to your code in order to load the data from the bundle instead of an external folder. This basically just means finding the correct path for the data.
1. First you need to find the filename of your app, as you can't assume the end-user won't have changed it. The following will do just that.
Global appName:String=StripDir(AppFile)+".app"
2. Next all you need to do is add the path to the data.
Global appData:String=appName+"/Contents/Resources/Data/"
3. Now just add the data path to the beginning of all your loading functions, for example...
Global gameLogo:TImage=LoadImage(appData+"Gfx/GameLogo.png")
If you're making your app for more than one OS then you may need to have different loading sections between the compiler directives ?macos, ?win32, ?linux, etc.
And that's it. Just remember to change the permissions again for any files you later update and there's no need to re-copy data for every rebuild of your app. The only things that get overwritten when an app is built are the binary in the "MacOS" folder and the icon in the "Resources" folder.
For information on creating universal binaries and changing the icon, check here.