Unity3D iOS BinaryFormatter 사용 중 ExecutionEngineException: Attempting to JIT compile method

ExecutionEngineException: Attempting to JIT compile method 'List`1__TypeMetadata:.ctor ()' while running with --aot-only.

  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.CreateMemberTypeMetadata (System.Type type) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.GetObjectData (System.Object obj, System.Runtime.Serialization.Formatters.Binary.TypeMetadata& metadata, System.Object& data) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObject (System.IO.BinaryWriter writer, Int64 id, System.Object obj) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectInstance (System.IO.BinaryWriter writer, System.Object obj, Boolean isValueObject) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteQueuedObjects (System.IO.BinaryWriter writer) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectGraph (System.IO.BinaryWriter writer, System.Object obj, System.Runtime.Remoting.Messaging.Header[] headers) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph, System.Runtime.Remoting.Messaging.Header[] headers) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph) [0x00000] in <filename unknown>:0 
  at GameDataTable.Save (System.String strKey) [0x00000] in <filename unknown>:0 
  at GameDataManager.Save (System.String strDataTableKey) [0x00000] in <filename unknown>:0 
  at PatchManager.EndPatch () [0x00000] in <filename unknown>:0 
  at PatchManager+<StartPatch>c__Iterator1.MoveNext () [0x00000] in <filename unknown>:0 


(Filename:  Line: -1)

 안드로이드와 PC에서는 잘 되던 유니티3D 에셋번들 패치 시스템이 iOS에서 문제를 일으키더군요. 패치 정보 데이터를 커스텀 객체화 또는 string로 시리얼라이저, 디시리얼라이저 하는데 있어 메모리스트림(MemoryStream)과 바이너리포멧터(BinaryFormatter)을 사용하는데 이 부분에서 iOS의 LLVM이 C#의 리플렉션(Reflection)등을 몇가지 지원하지 않아 이슈가 발생하네요.

 위 유니티스터디넷 링크글에 나온데로 .NET 2.0 subset설정만으로는 해결이 되진 않고 빌드 세팅 -> Other Settings -> Optimization -> Stripping Level 에서 Use micro mscorlib를 선택 후 빌드하면 해결됩니다.

이 블로그의 인기 게시물

CMake Windows에 설치하기

Unity3D 안드로이드 Keystore 생성하기

Unity3D iOS Plugin 만들어 연동하기