Xcode: How to set the current working directory to the relative path for the executable?

I have a command line executable in Xcode.

I am using Xcode 5.1. In the "Schema Editor" for the project in the "Parameters" section there is an option "Working directory". How to specify the path relative to the .xcodeproj file? I tried one period.

I need this because the code must assume the existence of files relative to the project directory.

+5
source share
2 answers

You can use Xcode build configuration variables , for example PROJECT_DIR , for example. setting the working directory to $PROJECT_DIR/.. will make it equal to the parent directory of your project directory.

+12
source

In the Xcode settings, you can change the location of the compiled binaries relative to your project or any absolute path that you like. Go to Preferences → Locations and click the Advanced... button under the Derived Data text box.

On the pop-up sheet, set Build Location to Custom , and then select the option you want from the drop-down list next to it and enter any paths that you like in the Products field.

Screenshot of Xcode Derived Data location diaglog

+4
source

Source: https://habr.com/ru/post/1203803/


All Articles