I would like to add an image to my C++ project in Xcode so that I can read that image and do something with it. How do I include the image into my project?
tried copy pasting both into my project and into the folder with my c++ source.
I would like to add an image to my C++ project in Xcode so that I can read that image and do something with it. How do I include the image into my project?
tried copy pasting both into my project and into the folder with my c++ source.
In Xcode 10, I can't put the image in the same folder as the executable, and I don't think it's a good idea anyway as this folder gets deleted when a clean is performed.
The solution I found when dealing with "Command Line Tool" projects in Xcode, is to modify or create a new Copy File Phase
(and not a Copy Bundle Resources
one) in Targets
> Build Phases
. But the default values should be modified:
The image should then be added to this phase (using the +
button). Beforehand, when adding the image to the project, selecting a target is not necessary, adding it to the Copy Files Phase
will do it automatically.
The code will then look like this:
std::string filename("input.bmp");
bitmap_image image(filename);
Put the image in the same folder with the executable i.e. with the file in the Products folder.