简体   繁体   中英

JSON data cannot be fetched in my App but displaying in XCode Debugging Area

Hi I am building an application for iOS using Unity3D. I am using UnityWebRequest to fetch data from my server (POST request). It works in my Unity Editor but not on my iPhone. However, I can actually see the JSON data I want in the debugging window in XCode, which is below,

You are using download over http. Currently unity adds NSAllowsArbitraryLoads 
to Info.plist to simplify transition, but it will be removed soon. Please 
consider updating to https.
Unhandled Exception: System.NotSupportedException: 
/Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System.Reflection.Emit/DynamicMethod.cpp(26) : Unsupported internal call for IL2CPP:DynamicMethod::destroy_dynamic_method - System.Reflection.Emit is not supported.
  at System.Reflection.Emit.DynamicMethod.Finalize () [0x00000] in <filename unknown>:0 
UnityEngine.UnhandledExceptionHandler:PrintException(String, Exception)
UnityEngine.UnhandledExceptionHandler:HandleUnhandledException(Object, UnhandledExceptionEventArgs)

(Filename:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
(MY JSON DATA)

So my JSON data display correctly in the debugger info, but why I cannot get it from my code? Like string data = MY_JSON_DATA and let me to parse?

I have checked ATS and this answer but it seems not work. Am I on the correct direction?

UPDATE: My Unity is 5.3.4p6, XCode: 7.3.1, iOS: 9.3

UPDATE2: JSON API: Newtonsoft.JSON, WebRequest: UnityWebRequest

Although a workaround for the problem was found in the comments, I'll mention here what this error message means. The error which occurred was:

Unhandled Exception: System.NotSupportedException: /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System.Reflection.Emit/DynamicMethod.cpp(26) : Unsupported internal call for IL2CPP:DynamicMethod::destroy_dynamic_method - System.Reflection.Emit is not supported.

The IL2CPP transpiler works ahead-of-time (AOT) only. So it cannot create code at runtime, hence, System.Reflection.Emit is not supported as the error message indicates.

Some JSON utilities emit code at runtime, but many have an AOT-friendly mode that does not. In this case, the workaround "works" because the JSON utility that is used now is AOT-friendly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM