Xcode does not create file

Whenever I write this code, I hear it is supposed to create a file with my message in it, but Xcode does not create it. I searched my whole computer and could not find the file. (I have a mac) Hear is the code:

#include <iostream>
#include <fstream>
using namespace std;

int main(){
ofstream myFile("thisfile.txt");
myFile << "This is my message";
myFile.close();

}

So basically whenever I run this, it just doesn't create "thisfile.txt."
I ran this code snippet in CodeBlocks on a Windows 7 PC, and it worked. Check the same folder as the .cpp or .exe files associated to the project.
For some reason Xcode stores it in a strange directory specifically

/Users/[name]/Library/Developer/Xcode/DerivedData/[projectname]/Build/Product/Debug

You can easily access that from Xcode by right clicking on the item below product file on the left hand side which is a preview of all the files then "Show in finder"

Spotlight doesn't search Library and also its a hidden file

if you want to be able to see it use this command
defaults write com.apple.Finder AppleShowAllFiles YES
in the terminal and relaunch finder
to undo that use this command
defaults write com.apple.Finder AppleShowAllFiles NO
and again relaunch finder

Hope i helped :D
Thank you so much! It worked perfectly!!!
Topic archived. No new replies allowed.