UIWebView Depreciation in xamarin forms

From April 2020, Apple announced new apps using the depreciated UIWebView will be rejected (for existing apps already in app store, the deadline is December 2020).  Fortunately for xamarin apps, this is quite simple. All that is needed is to add a flag to xamarin.iOS release configuration as described below

Right-click on your xamarin.ios project, select properties in Visual studio windows (or options for visual studio Mac) and choose ios Build and update the following parameters:

    1. Select  Release|iPhone configuration
    2. For linker behaviour, select either Link Framework SDKs only or link All
    3. Add this flag “--optimize=experimental-xforms-product-type” under additional mtouch arguments
You should have something similar to this

 

Visual Studio Mac Visual studio Windows
vsMac VSwindows

Save your changes and to ensure everything is as it’s suppose to be, check the .csproj file and you should have something similar to this.

csproj file

If you are lucky, that is all that is needed to remove this warning. If the issue still persists, read on.

Further troubleshooting…

However, if this is not the case, the next place to look will be in the Nuget packages. This can be a painful process especially if you have a lot of Nuget packages. The first step to ensure you have updated your Nuget packages to the latest versions. If the issue still persists, its time to further dig into you Nuget packages to find the culprit.  In time of writing this, one  common nuget that still uses UIWebView is Xamarin.iOS.MaterialComponents which can be found in found in below nugets as well:

  • Xamarin.Forms.Visual.Material
  • Xamarin.Visual.Material.Design

To fix this issue,

  1. Uninstall Xamarin.Forms.Visual.Material or Xamarin.Visual.Material.Design
  2. Add latest version of Xamarin.iOS.MaterialComponents
  3. Re-install Xamarin.Forms.Visual.Material or Xamarin.Visual.Material.Design
  4. Delete your bin/obj folders, clean and rebuild, then try again.

If the warning still persists, go through your Nuget packages analyzing them further or see this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s