4

I have code which generates resources which I want to save in a subdirectory of my $(PROJECT_DIR). How do I get the real path from this environment variable in code?

Tycho Pandelaar
  • 6,949
  • 7
  • 41
  • 68

2 Answers2

8

open the projects build settings and add SAVEPATH=@\"$(PROJECT_DIR)\" to the preprocessor macros.
Then you can get the project directory like this:

NSString *projectDir = SAVEPATH;
Matthias Bauch
  • 88,907
  • 20
  • 222
  • 246
0

I'm not sure if Xcode 3.2.6 has changed the way that () are used with environment variables, but I've found that using the following pre-processor macro works for me (@fluchtpunkt's answer gives me a compiler error):

PROJECT_DIR=@\""$PROJECT_DIR"\"

Then I can do:

NSString *savePath = [PROJECT_DIR stringByAppendingPathComponent:@"Save Folder"];
Nick Forge
  • 21,164
  • 7
  • 52
  • 78