What does “linked out by Xamarin” mean?

2019-08-10 00:51发布

问题:

In the Akavache docs, it says...

Add the following class anywhere in your project to make sure Akavache.Sqlite3 will not be linked out by Xamarin

What does "linked out by Xamarin" mean?

回答1:

The Xamarin.Android linker and Xamarin.iOS linker remove unused code from a compiled application. They inspect the compiled code and remove any code that doesn't appear as if it would be referenced during a run of the application.

Because this analysis is done on a compiled binary (e.g., a static analysis), there may be some cases where an application does use some code but the linker can't detect such a usage. Thus, the linker will remove this code, even though it is used. This will lead to problems when the application actually runs.

The quoted Akavache docs imply that Akavache.Sqlite3 is one of these cases, where the Xamarin linker will not be able to tell that it is being used, and thus the linker will remove it incorrectly. The docs recommend you add a reference to prevent the Xamarin linker from removing Akavache.Sqlite3 - i.e., to prevent the library from being "linked out" of your application by Xamarin.