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

孤者浪人 提交于 2019-12-24 09:39:22

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/38943806/next-step-to-make-binding-for-embedded-framework-for-xamarin-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!