UberGeoff
UberGeoff

Reputation: 212

How to solve AOT and code stripping on Unity3D iOS builds

What should you do when the IL2CPP compiler starts striping your code from your external assemblies (dll) in you iOS builds. Causing your JSON De/serialization code to break.

Upvotes: 3

Views: 1673

Answers (1)

UberGeoff
UberGeoff

Reputation: 212

1) Make sure you are using the Unity3d "tuned" version of JSON.Net. You can find the latest version here: Json.Net.Unity3D. This version does not make use of dynamic code - thus is "safe" for Ahead-of-time compilers.

2) Make sure you add the correct preservation lines into your Unity3D "link.xml" file:

<linker>
  <assembly fullname="AssemblyName.Common">
     <type fullname="AssemblyName.Common.*" preserve="all" />
   </assembly>
</linker>

The * will ensure that all namespaces as well as all classes are preserved - and will not be stripped.

That should do it.

Upvotes: 3

Related Questions