5

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!

2
  • 1
    Those files are Objective C++, not Objective C. I don't think swift bridging works with Objective C++ headers. Commented Apr 1, 2015 at 15:42
  • 1
    Is there any chance that i could import those objective C++ files? Commented Apr 1, 2015 at 20:35

1 Answer 1

4

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++)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, after a lot of cursing and DuckDuckGoing your answer was the one that actually made me understand why I couldn't use Objective-C++ headers (because they imported C++ headers) in my case.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.