-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift interop without ObjectiveC Headers #21549
Comments
Unfortunately binding swift is much more complicated than it may sound at first, but the good news is that support for swift is ongoing in the dotnet/runtime repository (see https://github.com/orgs/dotnet/projects/375 for an overview). It's still a ways away though, but in the meantime, the workaround is to expose Swift to Objective-C, and then bind that Objective-C API. For Swift APIs that you don't control, you can wrap them in your own Swift APIs and then expose those to Objective-C. |
The project you have linked is not public. Beside some issues and experimental projects I couldn't find any official documentation or statement around the exact plans. Things might happen behind the scenes but its hard from outside to judge the complexity, state and needs. Even though there were items like dotnet/runtime#93631 there isn't even something mentioned in https://learn.microsoft.com/en-us/dotnet/maui/whats-new/dotnet-9?view=net-maui-8.0 Unfortunately, in our case, it is not in our control to expose things to ObjectiveC as we are not the author of the library. Also it is not realistic to maintain the whole 3rd party wrapper ourselves. |
Sorry about that, all the work is done in public, so I assumed the project was as well, but I was wrong. Here are a couple of dotnet/runtime issues related to Swift support, you can also search for "swift" there.
That's because at this point it's not really useful for public consumption. Hopefully in .NET 10 we'll have something that can be used to bind at least a limited set of Swift APIs. |
Apple platform
iOS
Framework version
net8.0-*
Affected platform version
VS 2022, .net 8
Description
Background
iOS development is moving more and more away from ObjectiveC towards Swift. Library authors gradually stop supporting ObjectiveC interop and some language features like structs cannot even be supported through ObjectiveC. For ObjectiveC you can then use tools like Objective Sharpie to auto-generate some binding parts.
It seems the only way to do interop, requires MAUI developers to create their own interop library, redeveloping the API surface of the Swift library and maintining it.
This does not seem like a sustainable path to the future and leads to a problem in the iOS+MAUI ecosystem. Looking to Android+MAUI things are super easy to manage thanks to the nature of Java Interop.
What's next?
I was wondering if there is anything on the roadmap or alternative tooling which solves this problem? I am not that deep into the MAUI+iOS domain so bare with my lack of insights.
The key question is: Is MAUI maybe capable of using Swift libraries if you manually curate some binding code? Looking at the
.abi.json
files shiped for.swiftmodule
you could easily generate some C# glue code like Objective Sharpie. But I wonder about at least two things:Maybe there is already some tooling in the Market I have overseen?
Steps to Reproduce
.h
files as they do not contain all types.Did you find any workaround?
As mentioned above the
api.json
look very promising to do some code generation. But creating some code generator requires good knowledge about ABIs, calling conventions, .net runtime support (e.g. when inheriting classes and implementing interfaces)Build logs
No response
The text was updated successfully, but these errors were encountered: