error Machine info: macOS 10.13.5 Xcode 9.4 Swift 4.1 Default c++ compiler
I've created simple swift project and just added c++ file with header to it and Xcode created bridging header for me. I've initialised basic function in .cpp file, written prototype to .hpp file and included .hpp file in bridging header. When I've started typing in .swift file everything seemed to work: my cpp function name was suggested in .swift file in proper place and there were no warnings or errors. But, when I've tried to build this project, and got following: Undefined symbols for architecture x86_64: "_get", referenced from: _main in main.o
Here is source code:
// main.swift
import Foundation
print("Hello, World!")
var number = get();
// cppBackend.cpp
int get()
{
return 1;
}
// cppBackend.hpp
int get();
// test-Bridging-Header.h
#include "cppBackend.hpp"
//cppBackend.hpp second version
#ifdef _cplusplus
extern "C"
{
#endif
#include <stdio.h>
int get();
#ifdef _cplusplu
}
#endif