Can I create relative filepaths to images in an XCode SDL project?
I have to use absolute filepaths as it is, but it would be much easier if I could make the filepaths relative.
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
XCode usually runs your project from an internal directory used for development. One easy way to get the path to your program is to query NSBundle.
NSString * filename = @"images/my_image.jpg"; NSString * resourcePath = [[NSBundle mainBundle] resourcePath]; NSString * fullPath = [filename stringByAppendingPathComponent:filePath]; // fullPath is now the absolute path to the file.
You didn't specify the language, but if you are using C++, you can still use Objective-C inside a
.mm file, in the same project.