Sign in to follow this  

Relative file directoties in Xcode?

Recommended Posts

Okay so I'm using SDL and a .tmx parser to try and render some tilemaps from Tiled. I'm using Xcode with C++. So far so good.


But! The tilemaps' XML files refer to relative directories to find the tileset image. This is a problem because the compiled program is then looking relative to the build path rather than relative to the path of the tilemap.


TL;DR: Does anyone know how to access relative directories from the actual source code directories rather than the build directory?





Edit: Of course "Directoties" should be "Directories". You get the picture

Edited by Zotoaster

Share this post

Link to post
Share on other sites

The natural way would be to let the build settings copy all resource files to where the running application expects them. The directory containing the source files is obviously something that is available at development stage only.


That said, you can set the working directory (where all relative paths besides those anchored in bundles) implicitly begin. For this purpose edit the scheme of our target, select its Run action, under the Info tab select the Debug (or Release) configuration, and under the Options tab check "Use custom working directory" and fill in the absolute path below the checkbox.


Alternatively / additionally you can pass startup parameters and environment variables (you know argc, argv, envp) by using the Arguments tab.


If you want to branch from the working directory you have to implement it yourself by either path concatenation or program controlled temporary modifications of the working directory.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this