Skip to content
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

Remove the dynamic registrar #42

Open
Wenfengcheng opened this issue Apr 22, 2019 · 0 comments
Open

Remove the dynamic registrar #42

Wenfengcheng opened this issue Apr 22, 2019 · 0 comments

Comments

@Wenfengcheng
Copy link
Owner

Both the Xamarin.iOS and the Xamarin.Mac runtime include support for registering managed types with the Objective-C runtime. It can either be done at build time or at runtime (or partially at build time and the rest at runtime), but if it's completely done at build time, it means the supporting code for doing it at runtime can be removed. This results in a significant decrease in app size, in particular for smaller apps such as extensions or watchOS apps.

This optimization requires both the static registrar and the linker to be enabled.

The linker will attempt to determine if it's safe to remove the dynamic registrar, and if so will try to remove it.

Since Xamarin.Mac supports dynamically loading assemblies at runtime (which were not known at build time), it's impossible to determine at build time whether this is a safe optimization. This means that this optimization is never enabled by default for Xamarin.Mac apps.

The default behavior can be overridden by passing --optimize=[+|-]remove-dynamic-registrar to mtouch/mmp.

If the default is overridden to remove the dynamic registrar, the linker will emit warnings if it detects that it's not safe (but the dynamic registrar will still be removed).

It's possible to force the linker to keep the dynamic registrar by adding --optimize=-remove-dynamic-registrar to the additional mtouch arguments in the project's iOS Build options.

https://docs.microsoft.com/en-us/xamarin/cross-platform/macios/optimizations#remove-the-dynamic-registrar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant