There are some great answers on SO showing how to call C++ from Swift and Objective-C. For example in his answer to "Can I have Swift, Objective-C, C and C++ files in the same Xcode project?" SwiftArchitect shows how to call C, C++, Objective-C, Objective-C++, and Swift from Swift.
But the signatures of the C++ methods I can find in the examples are fairly simple. I want to call some C++ methods that take other C++ classes as input and output parameters. Let me show a dummy example. Here are two C++ classes.
class CPPClassA
{
public:
int myState;
int doSomethingAmazingWithTwoInts(int firstInt, int secondInt);
};
class CPPClassB
{
public:
int doSomethingAmazingWithTwoClassAObjects(CPPClassA &firstObject, CPPClassA *secondObject);
};
If I want to call CPPClassB::doSomethingAmazingWithTwoClassAObjects
from Swift how do I pass in the two CPPClassA
instances in my Objective-C++ wrapper for my CPPClassB
class?