Skip to content
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

Show a warning if ObjCBindingLibrary is used, recommend NativeReference instead #20358

Open
rolfbjarne opened this issue Mar 22, 2024 · 4 comments
Labels
binding-projects Issue or PR that affects binding projects enhancement The issue or pull request is an enhancement
Milestone

Comments

@rolfbjarne
Copy link
Member

From @AlphaNERD- on Thu, 21 Mar 2024 11:39:41 GMT

Hello .NET MAUI devs,

like many other devs i am migrating to .NET 8. I am working with a few native SDKs for Android and iOS respectively and i ran into a few binding problems which are close to be fixed.

During my ordeal i made what turned out to be a mistake and tried to bind every SDK using ObjCBindingNativeLibrary, thus introducing a build error involving clang++. I tried to bind some SDKs using ObjCBindingNativeLibrary and others using NativeReference and while i could push the build errors aside, i could not actually use the SDK i bound using ObjCBindingNativeLibrary during runtime.

Now i've bound every SDK again using NativeReference and while i'm still dealing with build errors (duplicate symbols, a potential regression in my specific case compared to Xamarin.iOS) i would like to know the following:

What is the difference between NativeReference and ObjCBindingNativeLibrary

If i had to guess it's that ObjCBindingNativeLibrary is some internal thing. I've seen a few people use in the Github Issues but none of the devs have actively discouraged the use of it AFAIK. I do know however that NativeReference works better with the SDKs and that Microsoft asks devs to use that to reference SDKs in .NET 8.

Copied from original issue dotnet/maui#21352

@rolfbjarne
Copy link
Member Author

From @drasticactions on Fri, 22 Mar 2024 08:00:28 GMT

I think you want the SDK repo, this is for the MAUI UI project and doesn't maintain that tooling. CC @rolfbjarne

@rolfbjarne
Copy link
Member Author

From @rolfbjarne on Fri, 22 Mar 2024 08:29:35 GMT

ObjCBindingNativeLibrary is an item that was introduced quite a few years ago, and is only used for embedding libraries in binding projects.

NativeReference is a newer item, with many more capabilities, and can be used both in a binding project and an app project.

The recommendation is to never use ObjCBindingNativeLibrary, only NativeReference.

@rolfbjarne
Copy link
Member Author

From @AlphaNERD- on Fri, 22 Mar 2024 08:50:49 GMT

Could we mark ObjCBindingNativeLibrary as deprecated, obsolete or otherwise give a compiler warning then?

Funnily enough, i was binding a library using ObjCBindingNativeLibrary and i could not use the library at all. When i tried to create an object instance of the SDK, i got an exception stating that the library could not be loaded. If ObjCBindingNativeLibrary is not about to be removed then i could share a sample project showcasing the problem. I'll have to ask for permmision though from Fujitsu.

@rolfbjarne
Copy link
Member Author

From @rolfbjarne on Fri, 22 Mar 2024 09:12:47 GMT

Could we mark ObjCBindingNativeLibrary as deprecated, obsolete or otherwise give a compiler warning then?

Yes, we could issue a warning if ObjCBindingNativeLibrary is used, so I'm moving this to the xamarin/xamarin-macios repository to track this.

@rolfbjarne rolfbjarne added enhancement The issue or pull request is an enhancement binding-projects Issue or PR that affects binding projects labels Mar 22, 2024
@rolfbjarne rolfbjarne changed the title Request for disambiguation of NativeReference and ObjCBindingLibrary Show a warning if ObjCBindingLibrary is used, recommend NativeReference instead Mar 22, 2024
@rolfbjarne rolfbjarne added this to the Future milestone Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binding-projects Issue or PR that affects binding projects enhancement The issue or pull request is an enhancement
Projects
None yet
Development

No branches or pull requests

1 participant