I have an xcode 6 swift project and I am trying to use C++ with it. In my project on the left I clicked 'new file' and I chose empty C++ file. Then I click yes and xcode generated Bridging-Header.h file.
In my new .cpp file I have #include <string>
. I tried to compile the file and everything compiled fine. Later I realized that I forgot to include the .cpp file in the bridging-header.h because my swift files didn't have access to a function in my .cpp file. When I added the #import "cplusplusfile.cpp"
in the bridging-header file, I get this error on this line:
#include <string> (!)'String' file not found
my goal is to get a string the user enters in a UITextField and send that string from my Swift files to a function in my C++ file so then I can use C++ to write that string to a file (I don't know how to read/write files in swift and couldn't find much on it..).
Would anyone know possible solutions? I looked online and other questions. One of the solutions was to change my cplusplusfile.cpp to cplusplusfile.mm. Unfortunately it didn't help :(