Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
Makes FFImageLoading linker-safe, so people can opt-in on what they want to bring as a dependency when using Linker configured as "Link All". This can help reduce app's sizes.
This closes #1317
If anyone wants the old behavior and doesn't care about the app final size, they can just add rules to their
linker.xml
. Unfortunately, linker does not allow assembly wildcards (AFAIK), so one rule must be used for each different assembly used, like this:My suggestion is adding a new page to the wiki named "Linker configuration", with this info:
If you are using Linker with "Link All" setting enabled, you might have to add rules to prevent Linker from removing types from FFImageLoading. Ideally you should preserve just what you are using, but if you prefer you can just add a catch-all rule to the Linker XML file as described in Xamarin documentation, although it can result in an app with larger size than you need.
If you decide to just preserve everything, you must add a rule for each FFImageLoading assembly referenced by your project. Please remember that packages have dependencies, so for example, if you are using
FFImageLoading.Forms
, it has a dependency onFFImageLoading
too, so you should add at least two rules, one for each assembly.Note: If you add a rule for an assembly you are not using, the linker task will throw an error, so you should just add the ones you need:
FFImageLoading has
Preserve=All
for all classes, which makes impossible for someone to remove unused code to reduce app size.🆕 What is the new behavior (if this is a feature change)?
FFImageLoading no longer preserves all, making it ok for Linker to remove anything that is unused, leading to a possibly smaller app size.
💥 Does this PR introduce a breaking change?
Yes, if someone is using "Link All", their app build might break with this change alone, so they can just fix it adding only what they need or they can configure their linker as stated above to keep the old behavior.
🐛 Recommendations for testing
Turn on "Link All", add the linker rules mentioned above and rebuild the samples.
📝 Links to relevant issues/docs
Linker configuration
🤔 Checklist before submitting