5
votes

I've tried to implement a project which I've found on github.

https://github.com/hossamghareeb/Facebook-POP-Tutorial

While I was implementing the .h and .m files I've got an error which was saying XCode could not find my 'iostream' file.

I'm working in SWIFT, using bridging-headers to use the framework. When I try to build the original project it works, but mine always fails.

enter image description here

How can I add my iostream file?

Thanks in advance!

1
Those files are Objective C++, not Objective C. I don't think swift bridging works with Objective C++ headers.Petesh
Is there any chance that i could import those objective C++ files?Hannes Van den Berghe

1 Answers

4
votes

Swift bridging does not support Objective C++ files. This means that any headers that consume or expose C++ entites (like std::vector; std::iostream) cannot be added to the bridging header.

The POP bridging header contains:

#import "POP.h"

You should really only #import that file in your own bridging header, rather than trying to #import all the .h files.

If you need to consume some of the API that's defined in .mm files that isn't exposed with an Objective C or plain C header, then you'll have to make your own header file that exposes it (and probably a back-end that implements what you've exposed).

The reason why you can use .mm files in a library that's being used by Swift is because all swift uses is the interface to those files - i.e. the .h files, and as long as those files are in plain C or Objective C, then you can make use of the code that is implemented in the .mm file. The .mm files are compiled by Objective C++ compiler (clang++)