Bridge Object

Any C++ class in cross-platform part of your project can be automatically bridged to other languages to expose it to UI code written in ObjC, Swift or Java. Just derive your class from scapix::bridge::object:

#include <scapix/bridge/object.h>

class user_info : public scapix::bridge::object<user_info>
{
public:
    //...
};

The lifetime of scapix::bridge::object should always be managed by std::shared_ptr / std::weak_ptr

void create()
{
    auto u1 = std::make_shared<user_info>(); // Ok
    auto u2 = std::shared_ptr(new user_info); // Ok
    user_info u3; // Wrong!!!
}

If you need the functionality of std::enable_shared_from_this, you can derive your classes from both scapix::bridge::object and std::enable_shared_from_this:

#include <scapix/bridge/object.h>

class user_info : public scapix::bridge::object<user_info>, public std::enable_shared_from_this<user_info>
{
public:
    //...
};