docs-maui icon indicating copy to clipboard operation
docs-maui copied to clipboard

Binding an objective-c library

Open davidbritch opened this issue 2 years ago • 0 comments
trafficstars

Xamarin doc: https://learn.microsoft.com/en-us/xamarin/ios/platform/binding-objective-c/

.NET MAUI sample: https://github.com/Sweekriti91/maui_ios_binding

Binding Obj-C - https://docs.microsoft.com/en-us/xamarin/ios/platform/binding-objective-c/ Updated the sample here : https://github.com/Sweekriti91/maui_ios_binding

Steps followed :

Steps

  1. Convert csproj file to SDK style.

    1. add the <IsBindingProject>true</IsBindingProject> project property
    2. Delete AssemblyInfo.cs OR keep old AssemblyInfo.cs file and set <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  2. Update for .NET 7 TFMs.

  3. For iOS, Known API Changes :

    • All references to System.nint, System.nuint and System.nfloat -> change to native int, native uint and System.NFloat
    • All methods on System.nint and System.nuint -> change to either equivalent calls on native int and native uint
    • If needed, add these new types NativeIntegerAttribute and CompilerGeneratedAttribute
    • All objects that inherit from either Foundation.NSObject or ObjCRuntime.DisposableObject that have constructors of the form .ctor (IntPtr) or .ctor (IntPtr, bool) -> change the IntPtr references to ObjCRuntime.NativeHandle.
    • All objects that inherit from Foundation.NSObject that have ClassHandle or Handle properties of type IntPtr -> change to type ObjCRuntime.NativeHandle
    • AutoGenerated tag remove from ApiDefinitions
  4. Build and fix build errors.

Resources

Xamarin.iOS -> .net7-ios - Project-file-properties - #11863


Associated WorkItem - 96026

davidbritch avatar May 30 '23 10:05 davidbritch