1

Solution here: How do I save files to $(PROJECT_DIR) from objective-c code?


My Xcode project is in:

/Users/MyUserName/Desktop/TheProject

I have some Objective-C code that writes a file here. Unfortunately this hard-coded path doesn't work on my co-worker's machine. He has the project in another directory like so:

/Users/AnotherUserName/Desktop/More/Folders/TheProject

I want to write the file to something like:

ProjectRootDir/

where I find that directory programmatically with iOS and Objective-C. How can I do that?

I looked around for an equivalent to $(SRCROOT) that's used in the project's build settings but I didn't find anything.

More info:

// currently trying this but it doesn't get me close to the project
NSString *path = [NSString stringWithFormat:@"%@/%@.plist", 
                                            documentsDirectory, 
                                            fileName];

I want to replace documentsDirectory with a path to the Xcode project on the local machine.

Community
  • 1
  • 1
SundayMonday
  • 19,147
  • 29
  • 100
  • 154
  • possible duplicate of [How do I print a list of "Build Settings" in Xcode project?](http://stackoverflow.com/questions/6910901/how-do-i-print-a-list-of-build-settings-in-xcode-project) – jww Apr 01 '14 at 00:34
  • How would I include `SRCROOT` when building the ouput string where I want to write the file? – SundayMonday Apr 01 '14 at 00:42
  • Those are environmental variables. I know they can be used from your scripts. I've never tried to use them from within a program. At worse, you just add a build script to write, for example `SOURCE_ROOT`, and then use it as a resource in the project itself. – jww Apr 01 '14 at 00:48

0 Answers0