Hello,
The main benefit of making something like AnyObject work with both Swift and another Objective-C implementation is that the same pointer can be shared between those universes without wrappers and the management of the wrapper class.
When we bound the Apple APIs to C#, we did not have this luxury, so our mapping had to keep a wrapper around the underlying representation, something like this:
// C# Code
class NSObject {
void *handle_to_native_object;
bool owns;
void destruct () {
if (owns) { NSObject.Release (handle_to_native_object);
}
}
class UIView: NSObject {
public UIView (void *handle, bool owns);
public UIView (bool do_not_initialize_me);
}
The above is a light level description, and not the full details, as it gets a lot hairier. For details see for example [UIView Constructor (UIKit) | Microsoft Learn].
Your constructors then need to deal with various different scenarios: creating a new object from scratch (the constructor in C# must call the Objective-C allocation + initialization of the object), when an existing object is being surfaced from a return value, you must track whether you own the object or not, and a special process (linked above) for subclasses that want to initialize the chain in a subclass.
And that is just the initialization. Then you need to deal with the owneship and reference counting, which can introduce cycles. I suspect that a Swift wrapper for a native refcounted system will run into the same set of problems that we had, which are not simple to solve. Possible, but with a lot of drawbacks.
If I was in charge of GNUstep, I would go as far as building my own Swift toolchain with the AnyObject semantics that bring the same level of interoperatbility as Swift has with Objective-C on Apple platform, the other path is just too painful, and it is far from a straight shot. That said, if someone wants to explore that particular avenue and learn more about the gory details of cycles, and how we had to deal with those, you can see the engine and code here GitHub - xamarin/xamarin-macios: Bridges the worlds of .NET with the native APIs of macOS, iOS, tvOS, and watchOS.
As for F# type providers, you should think of them as a dynamic stub generation, and that almost everything that you can do with that dynamic system can be done with a pre-processor, for the problem at hand, they are mostly a distrraction (the Gtk+ bindings for Swift, or the various Godot bindings for Swift use this pre-processor approach, and it works fine).
Miguel