【问题标题】:Xamarin forms ios app rejected due to Deprecated API Usage UIWebViewXamarin 表单 ios 应用程序由于已弃用的 API 使用 UIWebView 而被拒绝
【发布时间】:2020-06-10 19:42:41
【问题描述】:

我有一个带有 web 视图的 xamarin.forms 应用程序。每当我尝试将应用程序发布到苹果应用商店时,我都会收到Deprecated API Usage UIWebView 警告并且我的应用程序被拒绝。我看到了https://github.com/xamarin/Xamarin.Forms/issues/7323 中提出的问题。但我无法解决我的问题。我用这个渲染替换了 webView。

  public class MyWebView : WebView
    {
        public static readonly BindableProperty UrlProperty = BindableProperty.Create(
            propertyName: "Url",
            returnType: typeof(string),
            declaringType: typeof(MyWebView),
            defaultValue: default(string));

        public string Url
        {
            get { return (string)GetValue(UrlProperty); }
            set { SetValue(UrlProperty, value); }
        }
    }

在 ios 部分

[assembly: ExportRenderer(typeof(MyWebView), typeof(MyWebViewRenderer))]
namespace WKWebViewDemo.iOS
{
    public class MyWebViewRenderer : ViewRenderer<MyWebView, WKWebView>
    {
        WKWebView _wkWebView;
        protected override void OnElementChanged(ElementChangedEventArgs<MyWebView> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                var config = new WKWebViewConfiguration();
                _wkWebView = new WKWebView(Frame, config);
                SetNativeControl(_wkWebView);
            }
            if (e.NewElement != null)
            {
                Control.LoadRequest(new NSUrlRequest(new NSUrl(Element.Url)));
            }
        }
    }
}

我还添加了 --optimize=experimental-xforms-product-type 作为额外的 mtouch 参数并发布了应用程序。还是被拒绝了。如何解决这个问题?任何帮助表示赞赏。

我的 xamarin.forms 版本:4.6.0.847

xamarin.ios 版本:13.16.0.13

【问题讨论】:

  • 不需要自定义渲染器来解决这个问题。您的链接器设置为什么?您是否使用任何可能引用 UIWebView 的第三方库或 nuget 包?
  • 我的链接器设置是 Link Sdk only
  • 另外,如果您要更新现有应用,Apple 只会警告您,您仍然可以在 2020 年 12 月之前发布。
  • 不,我没有更新,我正在发布一个新应用。它正在从 appstoreconnect 中删除
  • 尝试链接所有,同时检查 ipa 文件上的 grep 以查看导致问题的原因

标签: xamarin xamarin.forms xamarin.ios


【解决方案1】:

无法将此作为评论发布,因为我想分享一张图片。

这也发生在我之前,我设置了--optimize=experimental-xforms-product-type,但我仍然得到了那个错误。

我的问题是我为错误的配置设置了这些额外的 mtouch 参数。正如您在图像中看到的,确保将这些值放置在正确的配置和平台中!它应该与您用于创建存档的组合相同:

【讨论】:

  • 谢谢兄弟。这就是问题所在。它是为模拟器设置的。我是多么愚蠢
  • :) 发生在我们最好的人身上。我不敢相信我浪费了我的时间来创建档案并发布它,结果却得到了那个错误
猜你喜欢
  • 1970-01-01
  • 2020-08-20
  • 1970-01-01
  • 2020-08-23
  • 2021-05-05
  • 2020-12-28
  • 1970-01-01
  • 2022-01-25
  • 1970-01-01
相关资源
最近更新 更多