-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom NSView won't work if referenced only in storyboard (not referenced in the C#-code) #20605
Comments
Additional note - it is not necessary to reference the exact the view class in the code to make it work. It is sufficient to reference any type from the class library. For example, I added the new empty class called So, it looks like it is not a Xamarin problem, but some kind of general build system feature. However, in very specific Xamarin use cases, such a feature can cause strange behavior for the Xamarin apps. |
Thanks a lot for the report! The problem is that if you don't reference any managed code from the class library in your executable, the C# compiler won't add a reference to the class library into the main executable (which makes sense - why would the executable reference the class library if it's not used?). And when deciding which assemblies to add in the app bundle, we start with the main executable assembly, and recursively find all the referenced assemblies (we don't include every assembly referenced by the executable project, because that would make all apps incredibly huge). In theory we could:
There are a few of downsides:
So, since:
I don't foresee we'll decide to fix this, so I'm closing this issue. |
Thank you very much for your detailed explanation! I totally agree that it's a very rare edge case and I'm glad to see that even though it won't be fixed, there is now some sort of searchable explanation of what's going on and how it can be workarounded. Thanks again for this explanation and for all your work in general. |
Steps to Reproduce
NSView
with a background color)AppDelegate.cs
and comment out the lineMyView test;
Expected Behavior
Nothing has changed, the light blue rectangle is still there because we only commented a declaration without any instantiation or anything else meaningful.
Actual Behavior
The light blue rectangle is missing.
Environment
Version information
Build Logs
msbuild.binlog.zip
Example Project (If Possible)
UiFromClassLib.zip
Additional information
MyView
(MyView.xib + MyView.cs
) which provides the colored background.MyView
is only referenced in the main app storyboard (the custom view is added and thenClass=MyView
in the XCode Interface builder).MyView
is referenced only in the storyboard, it will not work.MyView
type in the main app code (see lineMyView test;
in theAppDelegate
), everything works fine.The text was updated successfully, but these errors were encountered: