I've been tasked with adding some c++ code into an iOS project.
The c++ code comes in the form of several libs (.a), and header files with the extension .hpp
I have added these files into the XCode iOS project, and added the paths to the library and header search paths in the project settings, but I am getting compiler errors.
For example, one of the .hpp files contains:
`#include <string>`
and the error I am getting is "String: No such file or directory"
In the same hpp file there is a namespace declaration:
`namespace FooBar`
and there is an error on this line is "expected '=', ',', ';', 'asm' or 'attribute' before 'FooBar'"
I came straight into iOS programming so my experience has been primarily with objective-c. Can anyone offer any advice in terms of the project settings, search paths etc in order to get the c++ working alongside 开发者_运维技巧the obj-c?
Thanks in advance!
It could be that the Objective-C file that's including this header isn't in Objective-C++ mode. Usually you fix this by making your implementation a .mm
file instead of .m
since the latter is pure Objective-C.
精彩评论