For some reason i need to use this native framework in my Xamarin.iOS app and the problem comes, that i have no idea how to make bindings properly.
So as i understood correctly, this framework also uses another one framework and i'm little bit confused, what exactly i need to do?
Questions :
- Do i need to implement static library(is this possible to do with native frameworks) as it shows on official documentation of Xamarin ?
- Can i make bindings for native framework that is using another framework too or i need to implement them separately?
- Maybe i should re-write all these native frameworks into C# version?!? (But here's appears another problem, frameworks uses ObjC and is hard to reproduce in C# for me)
- What is the best approach to achieve my goal?(maybe its not described and you can tell me more).
Any advice? Thanks!
This library is written in pure ObjC. There is only one example written by Swift. In view of the library code is relatively small, I recommend you re-write into C #
OK, finally i have made a Static Library, but something is going wrong and i can't use it on Emulator at current moment. :(
I will explain step by step how i have made an static library :
In Xcode IDE i have made Static Library project and after this i have copied all source files from repository to my project.
Via Carthage i have download this framework(As i have explained, source files uses this framework) and also i have added new category in Build Phases -> Copy Files (where i have selected framework) into my Static Library . And builded successfully(On Deployment Target 10.2)
.
Next, i have made MakeFile and successfully generated four Fat Binary .a library's without any problem.
Xcrun command shows :
Then i have created Binding Library project in Xamarin and added Fat Binary Static Library as Native Reference(i will show my .csproj file below) and also i have put the same for framework(i have copied inside to project path) that is linked inside of Static Library (maybe it's redundant?)
Also , i have made additional file that is called OSTransformation.framework.linkwith.cs with code:
Via Objective Sharpie i have been generated ApiDefinition.cs and Structs.cs. Command :
sharpie bind --output=OSMapKitAdapter --namespace=OSMapKitAdapter --sdk=iphoneos10.2 /MyPath/OSMapKitAdapter/OSMapKitAdapter/*.h
And the result is :
Generated code of ApiDefinition.cs looks like:
Structs.cs :
OK, now i got compile errors and as it shows on official tutorial of Xamarin bindings , i need to check Fields with [Verify] Attribute and after resolving problem with them needs to remove this Attribute , also add Protocol attribute and etc.
New version of ApiDefinition.cs :
New version of Structs :
The problem is that i'm getting this errors :
How looks my .csproj file of_ Xamarin.Bindings_ project :
It WORKS on real device, but on emulator still get errors this strange errors.
UPD:
Just make sure that you have choose "Link framework SDK only" on linker and works as excepted!