1

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.

1
  • from the C++ side of things, it doesn't really care - you can hardcode paths starting from the root node down to the file (in Windows: "C:\temp\text.txt") or relative paths ("text.txt") where it will look in the current tool's directory, or ("../text.txt") where it will look one folder up. so C++ doesn't care. VS, running directly from cmd line, and any decent IDE allow you to define paths so that should not matter either. Save them where you'd like, and someone will be along to give you the menu path for XCode where you can change the directory. but google can give you that too i'm sure Commented Apr 30, 2013 at 19:04

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.