简体   繁体   中英

Where does Xcode create .txt files to?

http://www.cplusplus.com/doc/tutorial/files/

I just finished executing this but I didn't get any file on my desktop.

So where does the.txt file get placed on my computer?

// basic file operations
#include <iostream>
#include <fstream>
using namespace std;

int main ()
{
    ofstream myfile;
    myfile.open ("example.txt");
    myfile << "Writing this to a file.\n";
    myfile.close();
    return 0;
}

Damn... I've seen this post never answered many times..

Here's the solution

In your project navigator when you're working in your current project there are many files. Try products (if I remember) and look for the executable file. Now go to the properties inspector or whatever is called. (Right side of your Xcode.)

There you will find somewhere a part called PATH the path that is written over there. It's the path where the executable runs. That means there is where you'll find all the files you create with your program.

Try it... that's how I manage and look my .txt files since sometimes I wanna give them some kind of formatting.

I hope I've solved your problem... cheers! ;)

Click on the executable in the Products tab on the left hand side, and you should see the path to it displayed on the right in the utilities section. This is where they are saved. On my computer this path is:

/Users/myName/Library/Developer/Xcode/DerivedData/CurrentXcodeProject-adsnvetbleazktcgitfymfcbhkkt/Build/Products/Debug/filename.txt

In the "current directory", meaning the working directory of the environment from which you ran the executable.

I can't tell you what that is, but in basic cases it may be the directory where the executable is located. In many other cases it may not be.

Performing a search for the file on your hard drive will reveal its location to you.

Right click on your product and select "Show in Finder". Thats opens the path to where the output files go. Also you can add input files there to be read in by your program.

Found best answer here: File creation in C++ on Xcode

Basically you can specify a known directory so that all files created go there.

If you are on Mavericks Right click in your user folder with your documents and pictures and stuff (~/Users/yourusername) Now right click and view options. Check "show library". Now follow to the path that the first user above said.

What I've always done when an application saves a file and I don't know where... is just go back to that application, and hit File>Save As...

So re-open Xcode and go to the "File" menu, and click "Save As..."

It will show you the same directory it just saved to.

I have checked the "Current Directory" but I believe I have to specify the location. Not even

~User/Desktop 

will work.

What I do is create an empty file with a the correct name on my desktop then drag that file into my Xcode project to get its path. I then delete the file.

Same with adding files to my project. I can add them from the File menu, but I will need to drag them in to the spot in my code where I want to reference them.

It is kind of convoluted but it is the only system I have.

Some of the answers are confusing. Here's the simplest solution. 1. Expand your Products folder on the left-hand side 2. Right click on the terminal icon(sorry I do not know what it's called) 3. Click show in Finder. You should be able to see your output file in there.

" Where does Xcode create .txt files to? "

You can decide where you want: follow these->

  1. " Product->Scheme->EditScheme "
  2. chose options tab in the new popup "options"
  3. "working directory" tick "use coatroom working directory" and locate the folder where you want.

The .txt file that you "create", or that you want too "read" has to keep in this folder.

In 2022, click on the project name in the "breadcrumbs" area above the editor. Select the correct thing in "Products", then in the right area, see "Full Path".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM