Simply put: What is the most effective way to share / reuse code between iPhone and Android builds?
The two most common scenarios I think would be:
You can use Scapix Language Bridge to automatically bridge C++ to Java and ObjC/Swift (among other languages). Bridge code automatically generated on the fly directly from C++ header files. Here is an example:
Define your class in C++:
#include
class contact : public scapix::bridge::object
{
public:
std::string name();
void send_message(const std::string& msg, std::shared_ptr from);
void add_tags(const std::vector& tags);
void add_friends(std::vector> friends);
};
And call it from Swift:
class ViewController: UIViewController {
func send(friend: Contact) {
let c = Contact()
contact.sendMessage("Hello", friend)
contact.addTags(["a","b","c"])
contact.addFriends([friend])
}
}
And from Java:
class View {
private contact = new Contact;
public void send(Contact friend) {
contact.sendMessage("Hello", friend);
contact.addTags({"a","b","c"});
contact.addFriends({friend});
}
}