Hi! I started using CXX interop in my project with Swift 5.7 (Xcode 14.2). My current problem is destructors! I catch same behavior in Xcode 14.3 Beta 2 and Swift 5.8.
I created a b2World instance from box2d and when I change properties like gravity, physic bodies or smth else, I receive a destructor event from C++. Looks like each update of b2World create a new instance or it's a bug. Can you help me with that?
Some screens:
box2d lib I have used:
I solved my problem. For reference types like b2World and b2Body I added next macro
#define AS_SWIFT_CLASS \
__attribute__((swift_attr("import_as_ref"))) \
__attribute__((swift_attr("retain:immortal"))) \
__attribute__((swift_attr("release:immortal")))
class B2_API AS_SWIFT_CLASS b2World
...
}
And all memory problems has gone. But now my constructors not available and std.allocator<b2World>() doesn't work for me =/