如何将 WidgetKit 扩展嵌入 Xamarin.forms?

How to embed WidgetKit extension into Xamarin.forms?

I have an application created in swift and a widget using WidgetKit extension in SwiftUI. Now I want to embed the widget extension into xamarin. I came across a microsoft document on how to embed WidgetKit support in Xamarin, the link is as: https://docs.microsoft.com/en-us/xamarin/ios/platform/ios14/#embedded-widgetkit-support\。现在,当我尝试按照文档中给出的方式嵌入它时,我遇到了一个错误,因为“同上”以代码 1 退出。 (MSB6006)。我已经参考了一些资料,但仍然无法解决。

P.S。如果对您有帮助,我已经添加了屏幕截图。

您需要保持本机应用程序和 xamarin ios 应用程序之间的 BundleID 相同,然后 Xamarin iOS 将 select正确的配置文件。

本机应用程序:

本机扩展:

Xamarin iOS:

此外,你会看到扩展和应用程序也需要使用相同的应用程序组。

现在配置文件将显示:

效果: