4
votes

I am building a Xamarin ios app and have been testing for a while but have ran into issues testing in release mode. When users start typing answer into textfield I change the background color and the text color of textfield. Here is my code:

set.Bind (currencyText).For (x => x.BackgroundColor).To (vm => vm.AnswerViewColor).WithConversion ("NativeColor");
set.Bind (currencyText).For (x => x.TextColor).To (vm => vm.AnswerTextColor).WithConversion ("NativeColor");

In debug mode on any device that I have tested on this works fine. In debug mode on simulator I get the error below and the text color doesn't change though the background color changes fine:

MvxBind:Warning: 66.81 Failed to create target binding for binding TextColor for AnswerTextColor

In release mode it doesn't appear to be working either as my text color stays white so my assumption is I'm getting the same error/warning there too. Any ideas? Also I tried changing my Linker Behavior from "Link SDK assemblies only" to "Link all assemblies" and that didn't help any in release mode either.

Just some other information when I originally built this I had this issue as well and ran across the link below:

MvvmCross Failed to create target binding for EditingDidBegin on iPhone

So I added this below which fixed my problem for the most part but led to where I'm at now.

e.g. include a file like https://github.com/slodge/NPlus1DaysOfMvvmCross/blob/master/N-38-Maps/Mappit.Touch/LinkerPleaseInclude.cs with a method like:

public void Include(UITextField textField)
{
    textField.Text = textField.Text + "";
    textField.EditingChanged += (sender, args) => { textField.Text = ""; };
    textField.EditingDidBegin += (sender, args) => { textField.Text = ""; };
    textField.EditingDidBegin -= (sender, args) => { textField.Text = ""; };
}

This is my first app so any help would be appreciated. Hopefully it's something easy that I have missed.

1
Does it work when you add NativeColorConverter to LinkerPleaseInclude.cs? - Wosi
I'm not sure I understand. Are you able to provide an example? - Ross Lewellyn
You refer to NativeColorConverter as string. Maybe the linker removes this class. So you should add something like new NativeColorConverter() to the Include method to prevent the linker from ignoring that class. I dont know if it solves your problem. - Wosi
Thanks for the comments, but I posted answer from Xamarin site. - Ross Lewellyn

1 Answers

6
votes

So thanks to PaulFarrow on this one, but I did as followed in the link I posted and added to the LinkerPleaseInclude, but needed to add this to it as well

public class LinkerIncludePlease
{
     public void Include(UITextField textField)
     {
         textField.TextColor = textField.TextColor;
     }
}