IOS错误Could not produce class with ID

运行环境

Unity 5.3.5f1 (IL2CPP)编译IOS版本

XCode Version 7.2.1 (7C1002)

Mac OS X 10.11.3 (15D21) (Mac mini)

iPhone 5,6,iPad

错误信息

Could not produce class with ID

Could not produce class with ID XXX.
This could be caused by a class being stripped from the build even though it is needed. Try disabling 'Strip Engine Code' in Player Settings.:<LoadWWWIEnumerator>c__Iterator99:MoveNext()

 

具体表现:可能是APP闪退,提示上示错误信息

解决办法

1. 在上面的错误提示中,有提示 disabling “Strip Engine Code

所以我们要做的就是在Player Setting – Other Setting,去掉勾选 Strip Engine

image

如果要Strip Engine

如果要Strip Engine,那就需要把不想被strip的添加进来。

1. 新建link.xml放在Assets目录下,里面添加不想被strip的dll的名字

ID查询: https://docs.unity3d.com/Manual/ClassIDReference.html

下面是导入高通Vuforia之后,SDK中默认的link.xml的内容

<linker>
    <!-- The following assemblies contain namespaces that should be fully preserved
         even when assembly stripping is used. Not excluding the assemblies below from
         stripping can result in crashes or various exceptions. -->
    assembly fullname="Vuforia.UnityExtensions">
        namespace ="Vuforia" preserve="all"/>
    </assembly="System"="System.Runtime.InteropServices"/>
        ="System.Collections.Generic;"="System.Linq;"="System.Text.RegularExpressions;"="System.IO;"="System;">
>

如果提示的ID的是Editor的,比如 AnimatorController(ID 91)属于Editor包里的,不能用link.xm加回来,可以在Resource下建一个空的prefab,在上面挂一个AnimatorController,打包时留下这个prefab就可以确保这个类不被strip掉了。

参考:https://forum.unity3d.com/threads/could-not-produce-class-with-id-91-ios.267548/

Unity的默认值

以Unity5.3.5为例

ios平台,默认勾选了 Strip Engine Code,且Script Background为I2CPP

image

android平台,默认disabled Strip Engine Code,且Script Background为Mono2x

image

相关文章

这篇文章主要介绍了Unity游戏开发中外观模式是什么意思,具有...
这篇文章主要介绍Unity中地面检测方案的示例分析,文中介绍的...
这篇文章主要介绍了Unity游戏开发中如何消除不想要的黄色警告...
这篇文章主要介绍了Unity中有多少种渲染队列,具有一定借鉴价...
这篇文章主要介绍Unity中如何实现Texture,文中介绍的非常详...
小编给大家分享一下Unity中DOTS要实现的特点有哪些,相信大部...