Bright Lee
Bright Lee

Reputation: 2325

Next step to Make Binding for embedded framework for Xamarin.iOS?

I'm trying to use Native iOS framework from BLE chip bender(nordic) on Xamarin iOS. this framework (iOS Native - swift) : https://github.com/NordicSemiconductor/IOS-DFU-Library/tree/master/documentation

  1. I made a fat framework with those iOS library. And I looked this doc. https://developer.xamarin.com/guides/ios/advanced_topics/embedded_frameworks/

  2. I imported it as Native framework on Xamarin.iOS project. And I want to use it.

Below code is from that I used when i'm making iOS native app. I will have to use it on Xamarin.

(part of my app's code(objc base) - using that library )

DFUServiceInitiator *initiator = [[DFUServiceInitiator alloc] initWithCentralManager: [DeviceManager getInstance].central target:[DeviceManager getInstance].connectedPeripheral];
[initiator withFirmwareFile:nil];
initiator.forceDfu = [[[NSUserDefaults standardUserDefaults] valueForKey:@"dfu_force_dfu"] boolValue];
initiator.packetReceiptNotificationParameter = [[[NSUserDefaults standardUserDefaults] valueForKey:@"dfu_number_of_packets"] intValue];
initiator.logger = self;
initiator.delegate = self;
initiator.progressDelegate = self;
// initiator.peripheralSelector = ... // the default selector is used

DFUServiceController *controller = [initiator start];
  1. So in Xamarin.iOS project. I will use framework that I just imported. And I tried declaring 'DFUServiceInitiator' class. But nothing works but gives 'could not be found' error. Maybe there is many things left I have to do. Yes, this can't be that easy.

Next step is 'binding(wrapping) framework to c#'? Could you guide little bit please?

Is this document I should look next? https://developer.xamarin.com/guides/ios/advanced_topics/native_interop/

or this? https://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/walkthrough/

Thanks.

Upvotes: 1

Views: 1499

Answers (1)

tequila slammer
tequila slammer

Reputation: 2879

You can not simply include a Objective-C or Swift library in you Xamarin project and use it by copying Objective-C or Swif code. You need to create a binding project to create wrapping-classes to get a .NET-api. And that is where Xamarin binding projects come into play.

So you should go with https://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/walkthrough/ and learn about how to build bindings for native libraries. Depending on the library it isn't that hard.

Upvotes: 3

Related Questions