josephsfusco
josephsfusco

Reputation: 11

Xcode 4 file input/output, command line tool C++

I'm trying to figure out where to save multiple .txt files so that i can have a command line tool project in Xcode read directly in from them while running it.

I understand that Xcode compiles everything to a folder, DerivedData, which i have saved in the same location as my source code for each project respectively.

can i save multiple .txt files anywhere in the DerivedData folder or include it in the build settings and phases so that when i run the command line tool i can type the name of a file, it will read in from that file.

Upvotes: 1

Views: 826

Answers (1)

gibertoni
gibertoni

Reputation: 1378

By default the compiled/linked binary will look into its own directory for files.

For example, my binaries are at ProjectName/Build/Products/Debug/ and therefore it will look for files from that dir.

  • You can use relative path from that folder to the outside.

  • Or, you can create a symbolic link to another directory (on Terminal):

    ln -s source_dir target_file

target_file must be located in the same directory as your binary. And you can reference the other files like "target_file/file1.txt", etc.

Upvotes: 1

Related Questions