codeFreak24
codeFreak24

Reputation: 201

Unity Project works only in Development Build on IL2CPP

I have a mobile app project which builds smooth and without any errors on Android. But when I try to build it to an iOS device, I get this error in Xcode:

Unable to find internal function `UnityEngine.Jobs.TransformAccess::GetWorldToLocalMatrix`
Unity.Burst.BurstCompilerHelper:IsCompiledByBurst(Delegate)
Unity.Burst.BurstCompilerHelper:.cctor()
Unity.Burst.BurstCompiler:Compile(T, Boolean)
Unity.Entities.ComponentSystemGroup:.cctor()
Unity.Entities.InitializationSystemGroup:.ctor()
System.Reflection.MonoCMethod:InternalInvoke(Object, Object[])
System.Activator:CreateInstance(Type, Boolean)
Unity.Entities.TypeManager:ConstructSystem(Type)
Unity.Entities.World:CreateSystemInternal(Type)
Unity.Entities.World:GetOrCreateSystem()
Unity.Entities.DefaultWorldInitialization:AddSystemToRootLevelSystemGroupsInternal(World, IEnumerable`1, Int32)
Unity.Entities.DefaultWorldInitialization:Initialize(String, Boolean)
Unity.Entities.AutomaticWorldBootstrap:Initialize()

Unity builds the project to Xcode just fine, and Xcode also seems to build the project to the device, but when it runs on the device, it throws this error and crashes... I tried to look up different solutions on the internet and I found some links but none of these worked so far:

https://forum.unity.com/threads/solved-unable-to-find-internal-function.777044/ https://forum.unity.com/threads/unable-to-find-internal-function-with-transport-library-on-ios.731471/

Any idea what could potentially cause this error? BTW, I'm using Unity 2020.2.1f1

EDIT | UPDATE If I build the project with "Development Build" enabled it runs normally on IL2CPP Android & iOS. But If I uncheck the Development Build, it crashes like before, on both Android and iOS IL2CPP builds. Strange. Any possible info on this? Building the same project on Mono on Android also works smooth... Looks like a Code Stripping error to me, I tried the following solutions:

None of these worked so far. :(

I also added a link.xml file into assets folder, it looks like this

    <linker>
  <assembly fullname="Unity.Collections" preserve="all" />
  <assembly fullname="Unity.Collections.Tests" preserve="all" />
  <assembly fullname="Unity.Burst.Tests" preserve="all" />
  <assembly fullname="Unity.Transforms" preserve="all" />
  <assembly fullname="Unity.Transforms.Hybrid" preserve="all" />
  <assembly fullname="Unity.Transforms.Tests" preserve="all" />
  <assembly fullname="Unity.Jobs" preserve="all" />
  <assembly fullname="Unity.Jobs.Tests" preserve="all" />
  <assembly fullname="Unity.Burst" preserve="all" />
  <assembly fullname="UnityEngine">
         <type fullname="UnityEngine.*" preserve="all"/>
         <type fullname="UnityEngine.Jobs.*" preserve="all"/>
         <type fullname="UnityEngine.Jobs.TransformAccess.*" preserve="all"/>
  </assembly>
</linker>

Upvotes: 3

Views: 2634

Answers (1)

codeFreak24
codeFreak24

Reputation: 201

After almost a week of struggles and a lot of debugging I found the problem. In short, the crash was caused by the Unity.Entities 0.17.0-preview.41 package. (ref https://docs.unity3d.com/Packages/[email protected]/manual/index.html)

Even if an empty project is built on IL2CPP scripting backend + Development build is unchecked and the above mentioned Entities preview package is installed the app will crash and you will probably get the same error as me.

I don't know if it was a code stripping error after all but I found out a strange thing, if the Entities preview package is enabled it's first in the Script Execution Order (which you can check in the Project Settings) and maybe that caused the issue of a missing Internal function. (as the Entities package is dependent on the UnityEngine.Jobs.TransformAccess but as the Entities package executes first, it can't find the Jobs yet, that's my logic behind this, but please correct me if I'm wrong)

I'm still not sure why I had that package installed in the first place, as I didn't even use it in this project, so removing it solved all my issues and the project now runs smooth. Maybe this will help someone who has a similar issue in the future. All I can say as conclusion is:

  1. Be careful with preview packages.
  2. Don't use Unity.Entities preview package until they fix this issue.

Upvotes: 2

Related Questions