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 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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM