【发布时间】:2020-09-16 04:43:24
【问题描述】:
我为 Xamarin iOS 创建了一个绑定项目。 我成功地添加了本机库,创建了 C# 绑定并解决了我发现的所有数百个错误,一旦我尝试运行该库(在 iPhone 模拟器上的应用程序中)就会出现此错误:
无法创建“MyNamespace.STPPaymentCardTextField”类型的本机实例:本机类尚未加载。
这里是objective-c中接口的签名:
@interface STPPaymentCardTextField : UIControl <UIKeyInput>
这是我在 C# iOS 绑定中得到的:
[BaseType(typeof(UIControl))]
[Protocol]
interface STPPaymentCardTextField : IUIKeyInput
我阅读了this stackoverflow 的答案并检查了构建我的库的架构,这是架构,考虑到我在 iOS 模拟器上运行它:
是:i386 x86_64
这是我用来构建库的脚本:
all: lib$(TARGET).a
lib$(TARGET)-i386.a:
$(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphonesimulator -configuration Release
clean build
-mv $(PROJECT_ROOT)/build/Release-iphonesimulator/lib$(TARGET).a $@
lib$(TARGET).a: lib$(TARGET)-i386.a
xcrun -sdk iphoneos lipo -create -output $@ $^
clean:
-rm -f *.a *.dll
请问我该如何解决这个错误?
【问题讨论】:
-
你好,你是用
assembly在项目中加载.a文件吗,如:[assembly: LinkWith ("xxx.a", SmartLink = true, ForceLoad = true)]? -
你好,不,我不这样做,我应该在哪里这样做?
-
嗨@JuniorJiang-MSFT 谢谢我浏览了文档,我只添加了这两行的文件:使用ObjCRuntime; [程序集:LinkWith("libStripe.a", LinkTarget.ArmV7 | LinkTarget.Simulator| LinkTarget.Arm64, SmartLink = true, ForceLoad = true, Frameworks = "")]
-
但是在这样做之后,我出现了错误的错误消息,错误属于这种类型:docs.microsoft.com/en-us/xamarin/ios/troubleshooting/…。告诉我 [Protocol] 在某些类上存在错误,而它在代码中,并且我引用的 dll 是最新的。
标签: c# ios objective-c xamarin.ios xamarin.ios-binding