Stripping - ajuna-network/Polkadot.Unity.SDK GitHub Wiki

Title: Using link.xml to Enable High Stripping Levels in Unity with Polkadot SDK

Overview

This wiki page guides using the link.xml file in Unity projects that integrate the Polkadot SDK. The link.xml file is essential for enabling high levels of code stripping while ensuring that necessary code for the SDK is preserved.

Understanding Code Stripping in Unity

Code stripping in Unity is a process that removes unused code to reduce the size of the final build. While beneficial for optimizing performance, aggressive code stripping can inadvertently remove crucial code, leading to runtime errors.

Recommended Approach

  • Start with Minimal Stripping: Initially, set the stripping level to 'Minimal'. This ensures that all necessary code is included and helps identify if any issues are related to code stripping.
  • Test Functionality: Thoroughly test your application to ensure all features and SDK functionalities are working as expected.
  • Incremental Adjustment: Gradually increase the stripping level, testing the application's functionality at each stage. This approach helps in identifying the optimal stripping level without compromising the application's stability.

Implementing link.xml

To facilitate higher stripping levels without disrupting the Polkadot SDK functionality, include the following link.xml file in your project:

<linker>
    <assembly fullname="StreamJsonRpc" preserve="all"/>
    <assembly fullname="Nerdbank.Streams" preserve="all"/>
    <assembly fullname="Newtonsoft.Json" preserve="all"/>
    <assembly fullname="Substrate.NetApi" preserve="all"/>
    <assembly fullname="Substrate.Hexalem.NET.NetApiExt" preserve="all"/>
    <assembly fullname="Substrate.Kusama.NET.NetApiExt" preserve="all"/>
    <assembly fullname="Substrate.Polkadot.NET.NetApiExt" preserve="all"/>
    <assembly fullname="Substrate.NET.Wallet" preserve="all"/>
</linker>

Cautionary Note

While the link.xml file allows for higher stripping levels, it is crucial to approach this incrementally. Aggressive code stripping can lead to unforeseen issues, especially in complex projects. Always ensure full functionality at each level of stripping before proceeding.

Additional Resources

⚠️ **GitHub.com Fallback** ⚠️