Xcode How to Read From a File
The default settings in Xcode make it confusing to figure out where to put a datafile to be read by your program, such as dictionary.txt if you are doing some word comparison program. To do this you can either 1. Find the default location, or 2. Change the default location. These two approaches are explained below.
Find the default location:
You have to put your data files in just the right directory for your program to read them. Within Xcode select the "File Folder" icon near the upper-left of the window. Then select the "Products" folder, which should display the executable version of your program. Right-click on it, and select Show in Finder. The resulting directory is where to put your data files for Xcode to read.
Change the default location:
If you want to have your data files close to your source code, then this is the option for you. Note that this change affects all projects, not just the current project.
While in Xcode, at the far upper-left of your screen select Xcode and then Preferences:
Within Preferences select Locations and then Advanced:
Within the Advanced window, under "Build Location" select Custom.
Within Custom select "Relative to Workspace" in the dropdown menu.
Enter values for Products and Intermediates. Putting a single period in the Products field will end up making a directory called DEBUG in the same location as your main.c file. Entering "Intermediates" in the field below it will also make a directory called "Intermediates" there.
The executable version of your program will be in the DEBUG directory, which is where you should put your data files: