在解决方案中创建Xamarin.Mac
绑定项目。
添加NativeReference
到:
/System/Library/Frameworks/CryptoTokenKit.framework
使用以下方法绑定它sharpie
:
sharpie bind \
-o CryptoTokenKitFramework \
-namespace CryptoTokenKit \
-sdk macosx10.13 \
-f /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CryptoTokenKit.framework
绑定项目模板与 Sharpie 的输出不匹配,因此您可以删除 ApiDefinition.cs 并添加 ApiDefinitions.cs 或直接覆盖创建的模板:
mv CryptoTokenKitFramework/ApiDefinitions.cs CryptoTokenKitFramework/ApiDefinition.cs
将有许多属性,例如(版本将在它们之间发生变化):
[Watch (4,0), TV (11,0), Mac (10,12), iOS (10,0)]
由于这些是iOS、Watch、TV 上的私有框架,因此将这些平台剥离。保留Mac
属性和原始版本:
[Mac (10,11)]
注意:PlatformAttribute
已过时但sharpie
仍在使用它(假设向后版本兼容性(?)),因此Introduced
如果您真的想清理构建输出,可以使用:
[Introduced (PlatformName.MacOSX, 10, 11, PlatformArchitecture.Arch64)]
将有一些[Verify]
属性需要审查/更正。即TKSmartCardUserInteraction.Cancel
并且 TKSmartCardSlot.MakeSmartCard
都应该是方法而不是属性。
示例/生成:
// -(TKSmartCard * _Nullable)makeSmartCard;
[NullAllowed, Export ("makeSmartCard")]
[Verify (MethodToProperty)]
TKSmartCard MakeSmartCard { get; }
更正:
// -(TKSmartCard * _Nullable)makeSmartCard;
[NullAllowed, Export("makeSmartCard")]
TKSmartCard MakeSmartCard();
修复其余的[Verify]
属性和编译器错误,有一堆错误的方法签名、指针、返回类型等生成并需要更正。
注意:为了让您的生活更轻松,请确保您使用的是最新Sharpie
版本:
Version: 3.4.0
SHA1: c12859dac8d43121b5a9ed866a0db8409f9df817
URL: https://dl.xamarin.com/objective-sharpie/ObjectiveSharpie-3.4.0.pkg