I'm in the proces of making an app for interacting with smartcards. For that I'd like to use the CryptoTokenKit Framework which is standard on a Mac (located at /System/Library/Frameworks/CryptoTokenKit.framework).
This link says that it's possible to bind frameworks in a Mac project: https://developer.xamarin.com/guides/cross-platform/macios/native-references/
I've created an ApiDefinition.cs file and a StrucsAndEnums.cs file using the following sharpie command: sharpie bind -framework ./CryptoTokenKit.framework -sdk macosx10.13 -o ~/CryptoTokenKitBinding
I can't find any info on the internet how to implement the above mentioned files and start using the framework.
Create a
Xamarin.Mac
binding project within a solution.Add a
NativeReference
to:Bind it using
sharpie
:There is a mismatch between the binding project template and the output of sharpie, so you can either delete ApiDefinition.cs and add ApiDefinitions.cs or just overwrite the template created one:
There will be a number of attributes like (versions will change across them):
As these are private frameworks on iOS, Watch, TV, so strip those platforms out. Leave the
Mac
attribute and the original version:Note:
PlatformAttribute
is obsolete butsharpie
is still using it (assuming backwards version compatibility(?)), so you can useIntroduced
if you really want to clean up the build output:There will be a few
[Verify]
attributes that have to be reviewed/corrected. i.e.TKSmartCardUserInteraction.Cancel
andTKSmartCardSlot.MakeSmartCard
should both be methods not properties.Example / Generated:
Corrected:
Fix the rest of the
[Verify]
attributes and compiler errors, there are a bunch of bad method signatures, pointers, return types, etc.. that are generated and need corrected.Note: TO make your life easier, make sure that you are using the latest
Sharpie
version: