For example,
to create a C++ file named macos/Classes/native_add.cpp,
use the following instructions. (Note that the template
has already created this file for you.) Start from the
root directory of your project:

cat

> macos/Classes/native_add.cpp

<<

EOF

#include <stdint.h>

extern "C" __attribute__((visibility("default"))) __attribute__((used))
int32_t native_add(int32_t x, int32_t y) {
    return x + y;
}

EOF

On macOS, you need to tell Xcode to statically link the file:

In Xcode, open Runner.xcworkspace.

Add the C/C++/Objective-C/Swift
source files to the Xcode project.

Step 3: Load the code using the FFI library