Bug 30580 - Custom renderers in separate ios projects are "not found" (or not used) at runtime
Summary: Custom renderers in separate ios projects are "not found" (or not used) at ru...
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 1.4.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-05-29 07:53 UTC by softlion
Modified: 2015-05-29 10:35 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description softlion 2015-05-29 07:53:56 UTC
Repro:

- create a Forms project
- add a PCL project and create a class that subclass a Button for example (name it SubclassedButton)
- add an iOS library project, and create a custom renderer for the SubclassedButton

Reference these projects into the Forms.iOS project.
The button will be displayed, but the custom renderer will never been executed.
Only on iOS
On Android it works as expected.

  <package id="Xamarin.Forms" version="1.4.3.6358-pre2" targetFramework="xamarinios10" />


Microsoft Visual Studio Ultimate 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.51209

Xamarin   3.11.584.0 (1a920cd)
Xamarin.Android   5.1.2.1 (4ab8d98a62adf8f28223cef18fa63f06e87835a9)
Xamarin.Forms Intellisense   1.0
Xamarin.iOS   8.10.1.0 (fce006eae308515fc1eaf85fcc0f90699d9c7e8b)

Build Host: ios 8.10.1.64 / BH 3011.0.582
Comment 1 Rui Marinho 2015-05-29 10:35:07 UTC
Hi, the problem you are hitting is that Xamarin.Forms only looks at loaded assemblies. That means If you are putting renderers into a custom library, then that library needs to be loaded before Forms.Init is called. That means you must have used some type in the library already.

Here's a workaround for this case, in the custom library add a dummy class:

public static class CustomControls
{
   public static void Init() { }
}

Then, call the above Init method just before you call Forms.Init in your platform assemblies.

Thanks
Regards
Xamarin Forms Teams