0

I've been trying to get a build archived for IOS by using Visual studio and the "Pair to mac" functionality. However, when I try and do a release build, I get this error:

Error processing the method 'System.Void ProjectName.iOS.Renderers.IOSWebViewRenderer::.ctor()' in the assembly 'TextFlowMobile.iOS.exe': Object reference not set to an instance of an object TextFlowMobile.iOS

My code for this renderer, that is for WKWebView is as follows:

namespace TextFlowMobile.iOS.Renderers
{
    public class IOSWebViewRenderer : WkWebViewRenderer
    {
        public override WKNavigation LoadHtmlString(NSString htmlString, NSUrl baseUrl)
        {
            try
            {
                if(htmlString != null && baseUrl != null)
                {
                    // Add additional HTML to ensure fonts scale correctly and don't appear extremely small and almost unreadable
                    var iOSHtmlWithScaling = htmlString.ToString().Insert(0, "<meta name='viewport' content='width=device-width,initial-scale=1,maximum-scale=1' />");
                    return base.LoadHtmlString((NSString)iOSHtmlWithScaling, baseUrl);
                }
                else
                {
                    return base.LoadHtmlString(htmlString, baseUrl);
                }
            }
            catch (Exception)
            {
                //System.Diagnostics.Debug.WriteLine(ex);
                return base.LoadHtmlString(htmlString, baseUrl);
            }
        }
    }
}

As you can see, I don't override the constructor at all. I really don't see why this happens, especially since it builds (and deploys on a simulator on the connected mac) perfectly fine for debug.

My current config is Release | iPhone | ProjectName.iOS | Remote Device

I really appreciate any help!

Jc781
  • 21
  • 4

1 Answers1

1

This error occurred because I had an Obfuscator running on the release version of the code. When I tried to archive this, I imagine it couldn't properly compile this renderer because it was obfuscated.

Jc781
  • 21
  • 4