-
Notifications
You must be signed in to change notification settings - Fork 201
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 Bindings - General questions #2743
Comments
Hello @kusc-leica, Thanks for reaching out, I'm happy to discuss your usage scenario! Would you mind sharing some more details about your particular use case? It would allow us to offer you better guidance. What version of .NET do you target? Is it .NET 9 or .NET 8? Also, do you need to use some particular API from the library you shared, or you need to wrap all of the public API surface of the said library? About your dylib question - the library which you want to use does have |
Sure! Basically the usecase is to wrap a iOS Swift Cocoapod library for usage in .net MAUI net8.0 (net9.0 might still be in the acceptable timeframe though). I think the usecases might span quite the typical needs of using a SDK from a 3rd party vendor:
There might be some special Swift constructs I am simply not aware of but generally we are just interested into "using" the library. Typical usage of this particular library looks like this: https://docs.notifica.re/sdk/v4/ios/implementation/register/ I fear the implementatoin of protocols in .net objects might be the most problematic scenario while other bits like structs and class methods should be comparably easy.
While temporarily we might be able to limit ourselves to only certain areas we really use, but eventually the idea would be to wrap the whole public API surface.
Seems the assumption I a had was correct that this is currently just a "simplification" in the code. The code currently expects a runtimelab/src/Swift.Bindings/src/Program.cs Line 214 in 8f46441
|
Thanks for providing all the details!
As you have already seen we shipped a lot of .NET runtime support for Swift in .NET 9. Those changes enable to call Swift in far more natural way. The story is not complete yet, but the current feature set should allow you to bind many Swift constructs. You can see an example of using those features to bind Apple CryptoKit here: .Net 8 version for comparison (it required considerable amount of custom swift glue code): The tooling on That said, currently the tooling is in experimental phase. It should generate bindings for some constructs (e.g. structs, simple methods), but it will fail on others (e.g. classes). Inspecting the test directory would give you the most up-to-date picture of the current support: So, running the tooling might give you something to start with, but majority of the work will be writing bindings by hand. At the moment, looking at your use case, this means classes, extensions, protocols and parts of enums. Some ideas how to do so might be found here: Also, in order to use the tooling (or .NET 9 Swift support in general) you need to ensure that the library is built in Should you decide to go down this path, we will be happy to discuss any rough edges you will find on the way.
Right, thanks for pointing this! |
Hey there.
We are currently struggling a bit with the support of Swift in MAUI. We have a library which doesn't expose a ObjectiveC interface but we are in dire need of a binding library for a 3rd party product. After failing to use other tools I stumbled over the
feature/swift-bindings
branch in this repository and it kind-a looks promising.As Microsoft has not really published yet any details on Swift interopability support but there seem to be a lot ongoing in development:
I understand the "experimental" nature of the ongoing development but still would have following questions and inputs:
.abi.json
, in the Cocoapod we wanna use, there is no dylib in the package. (Notificare, Cocoapod). I wonder if this is currently just a simplification or there is a design problem there. I saw that the dylib is only needed in some special scenario but still it is required to exist.Any help is highly appreciated so we could create some wrapper for the iOS library we need.
The text was updated successfully, but these errors were encountered: