iOS Guides | Samples

Foundation.LinkerSafeAttribute Class

Assembly-level attributed used to inform MonoTouch's linker that this assembly can be safely linked, regardless of the system linker settings.

See Also: LinkerSafeAttribute


public sealed class LinkerSafeAttribute : Attribute


Use this attribute in your assembly if it is safe to perform linking on it, regardless of the user default setting to "Link only Framework Assemblies.

The use case for this attribute are third-party libraries that are safe to be linked because they have either safe to be linked because they do not depend on members or methods to be compiled in to work, or if they do, they used the PreserveAttribute to preserve those classes.

The default configuration for MonoTouch projects is to link only the SDK assemblies, and not link user code or third party assemblies. But many third party assemblies might want to reduce their on-disk footprint by informing the linker that they are linkable. Use this attribute in those cases.

You do not actually need to take a dependency on the Xamarin assemblies, for example, if you are a third-party developer that is creating a component or nuget package that is safe to be linked, you can just include the LinkerSafe attribute source code in your application, and the Xamarin linker will recognize it.

To use, merely add the following snippet to your source code in your assembly:

C# Example


To use in an assembly, without taking a dependency in Xamarin's assemblies:

C# Example

class LinkerSafeAttribute : System.Attribute {
    public LinkerSafeAttribute () {}



Namespace: Foundation
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions:

The members of Foundation.LinkerSafeAttribute are listed below.

See Also: Attribute

Public Constructors

Default attribute constructor.