Date first published: 29th May 2020
Since the 30th of April, many software houses and developers using Microsoft Xamarin will have fallen foul of the dreaded 'Deprecated UIWebView' issue which stops new apps being released to the Apple Appstore!! Microsoft has provided a fix in the latest versions of Xamarin but upgrading is fraught with dangers and may not even be possible for many companies. As a result, businesses are now faced with the painful decision of either dropping IOS support or significantly delaying the launch of their new apps.
Having spent hours trying to unsuccessfully upgrade Xamarin I fixed the problem directly within the old version of the Xamarin code myself. It took less than 40 minutes before I had a working build deployed to the Apple store with minimal disruption to my own code.
In this latest article of my Streetwise Tech series I present the solution in easy to follow steps with screenshots and samples taken from live apps. I also describe some of the issues encountered in the upgrade attempt to help anyone considering that route.
Please note that this solution works because I'm not using a WebView however it may offer useful insights to those who do but are still facing a challenge with upgrading.
I'm running Xamarin Forms version 2.4 with Microsoft Visual Studio 2015. I kicked off a project 2 years ago building a game to run on Apple, Google and Amazon. My game, Otherworld: Epic Adventure, was successfully deployed in March and now I want to release a number of the sub games as separate apps in their own right.
Getting these games out quickly is an essential part of my marketing strategy. Besides, the code is all working and I don't want to redesign or redevelop it right now.
The other point I must mention is that I don't own an Apple Mac, (yes it really is possible to build IOS apps without having one), I run all my tests initially against Windows and Android and then I use Microsoft App Center to perform the IOS build. Only after the app is available on the Apple App Store do I then test it on an IPhone.
Depending on your situation, upgrading to the new version of Xamarin Forms (Microsoft recommends 4.6 or higher) may have a massive impact on your code base and your delivery timescale. Only after loosing most of my hair in the attempt did I decide to rethink and go with the solution I present in this article.
However, here are some of the bigger problems I encountered trying to move from Xamarin Forms version 2.4 and Visual Studio 2015 to the latest version 4.7. These issues have solutions but they are time consuming or may have a large impact to the project.
The Nuget Package Manager in Visual Studio 2015 doesn't recognise version 4.6 as the package name format is unsupported. Straight away there is an issue as the maximum version of Xamarin that 2015 recognises is 4.5 which doesn't contain the necessary fix.
I fixed this by installing the Nuget packages from the command line but this causes the package manager UI inside VS to break and I'm forced now to use the command line for all Nuget tasks.
The new version of Xamarin lays out the screen differently. Immediately after installing the latest Xamarin Forms and rebuilding I find that none of my screens display. Everything is showing a black background with no controls. First major breaking change - I'm going to have to tweak if not re-code all my screens to get them to work which will require everything to be retested.
Visual Studio 2015 didn't cut the mustard so I then tried to use 2019 which seems sensible as it should easily support the latest versions of Xamarin.
2019 happily ported over my older solution and project files but a number of my projects wouldn't load. Most notably the Windows build as well as the UML design project. One of the reasons I started this with 2015 (I could have used 2017) was because I wanted the UML designer which had been deprecated in 2017.
The new version of Xamarin also wanted a new version of the Android SDK. Visual Studio 2019 kindly downloaded it for me in the background - taking up 45GB of disk space in the process. Actually, it used all my C drive, crashed Visual Studio and corrupted the Android installation while doing it.
The crux of the problem is a control inside Xamarin Forms that references the UIWebView class from the Apple SDK. The UIWebView is deprecated and all references to it must be removed from Xamarin Forms before a new app can be uploaded.
The Microsoft article contains full details of the issue:
https://devblogs.microsoft.com/xamarin/uiwebview-deprecation-xamarin-forms/
So how can this actually be fixed? Here is a step by step guide with screenshots to help.
This issue is in Xamarin.Forms and in particular the Xamarin.Forms.Platform.IOS project.
https://github.com/xamarin/Xamarin.Forms/tree/2.4.0/Xamarin.Forms.Platform.iOS
Now we've got the projects and references sorted out its time to actually change the code.
Once the IPA file is built you can go ahead and upload it, as you can see its accepted by the App Store.
I was also able to distribute it via TestFlight and get it down successfully onto my IPhone.
At the start I didn't even think about modifying Xamarin itself but actually it was extremely easy. 40 minutes later I had a working build on the AppStore and now I also have my own version of Xamarin. This gives a lot of control and the ability to fix minor issues in the platform rather than work around them or blindly upgrade to new versions.
I will of course use the latest version with new projects, but I can now complete my current work without major disruption to the code or timescale.
I hope you have found this article useful. If there is any information missing then please leave a comment and I'll update the article. Also, please check out my other article on designing mobile apps to support testing or find out about my mobile project Otherworld: Epic Adventure.
Thanks and stay safe!
Graeme Clarke