IOS错误Could not produce class with ID

本文为作者原创,转载请注明出处:https://www.cnblogs.com/zhaoqingqing/p/6080075.html



运行环境#

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 fullname="Vuforia" preserve="all"/>
    </assembly>
    <assembly fullname="System">
        <namespace fullname="System.Runtime.InteropServices" preserve="all"/>
        <namespace fullname="System.Collections.Generic;" preserve="all"/>
        <namespace fullname="System.Linq;" preserve="all"/>
        <namespace fullname="System.Text.RegularExpressions;" preserve="all"/>
        <namespace fullname="System.IO;" preserve="all"/>
        <namespace fullname="System;" preserve="all"/>
    </assembly>
</linker>
复制代码

如果提示的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

作者:赵青青   一名在【网易游戏】做游戏开发的程序员,擅长Unity3D,游戏开发,.NET等领域。
本文版权归作者和博客园共有,欢迎转载,转载之后请务必在文章明显位置标出原文链接和作者,谢谢。
如果本文对您有帮助,请点击【推荐】您的赞赏将鼓励我继续创作!想跟我一起进步么?那就【关注】我吧。
posted @   赵青青  阅读(5008)  评论(0编辑  收藏  举报
编辑推荐:
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· 2 本地部署DeepSeek模型构建本地知识库+联网搜索详细步骤
点击右上角即可分享
微信分享提示
CONTENTS