Directory structure question

General discussion about the R.U.B.E editor
Post Reply
Eddy8555
Posts: 42
Joined: Sat Apr 27, 2013 3:01 pm

Directory structure question

Post by Eddy8555 »

I've been working with RUBE for a few weeks now and loving it. But so far my exported .json, and all my images where in the same directory. Now I need to put some new images in a different directory, but something doesn't seem to work.

I believe I'm setting the image to the body correctly in the editor (the same way it worked so far) and the structure seems to be correct in the json, like this: "file" : "../letters/b.png" but the bodies show up empty on the screen.

What am I missing?
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Directory structure question

Post by iforce2d »

I will assume from previous correspondence that you are talking about deploying to iOS.

First thing to point out is that using ".." will most likely not work because it's trying to reference outside the bundle, which although it might work on the simulator if you're lucky, it will almost certainly not work on the device.

When you add files to an Xcode project you are given the option of creating 'groups' or 'references' for folders. If you choose 'groups' you get little yellow folders in the Xcode project tree, and these files will be copied into the app bundle by throwing everything into the same folder (the root directory inside the bundle), completely ignoring the original folder structure of your resources. Using this method will work ok if all your images are in the same folder as the exported .json file.

If you choose 'references' you get little blue folders in the Xcode project tree, and the original folder structure will be preserved when copied into the bundle. Using this method should allow images to be loaded using a relative path from the exported .json file (as long as the relative path does not go outside the bundle with "..").

Unfortunately the 'references' method has some unfortunate drawbacks. A folder added as a 'reference' means that everything under that folder will also be added recursively, and Xcode will copy everything under it to the bundle each time you build. Although this has the benefit that you don't have to explicitly add new images to the project as you create more of them, it does not remove files from the bundle that have been deleted from the original folder structure, and on the whole it seems to be quite unreliable. I wish there was a middle ground method where you could just add files to the project without losing the folder structure, and without the forced recursive adding.

As is often the case with Apple software, they seem to be trying to help you, but their help is unwanted, misguided and very restricting. I have wasted many long hours cleaning, rebuilding, deleting derivative data, inspecting the resulting bundle contents etc, trying to figure out what the hell was going on. As long as you are aware of how it works and you are prepared to design your whole project and svn structure around how Apple thinks you should do it, you will be fine. :roll:
Post Reply