Reputation: 2325
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
I made a fat framework with those iOS library. And I looked this doc. https://developer.xamarin.com/guides/ios/advanced_topics/embedded_frameworks/
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];
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
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