在unity中引入一些库之后,在mono模式下正常,但是切换成il2cpp之后就产生崩溃
这种现象一般可能是因为代码剥离时被删除了
这时可以在Assets目录里创建一个link.xml的文件,这个文件的作用是告诉编译器,哪些类定义要保留
具体说明参考官方说明https://docs.unity3d.com/2017.4/Documentation/Manual/IL2CPP-BytecodeStripping.html
在工程中引用Newtownsoft.Json库就会有这个问题,如上方法加上以下配置可以解决
<linker>
<assembly fullname="System.Core">
<type fullname="System.Linq.Expressions.Interpreter.LightLambda" preserve="all" />
</assembly>
</linker>