std::fstream and OSX - Why can I not load a file with my raw executable?
Your executable is looking in the current working directory (CWD).

When run from Xcode, Xcode actively changes the current working directory to where your executable has been built.

When run from the Finder on macOS, the current working directory will not be the directory of your executable. Thus the executable can not find the text file.


Use the getcwd or std::filesystem::current_path function to determine the current working directory from within your executable. See Get path of executable for ways to get your executable's path at runtime.