简体   繁体   English

无法在我的应用程序中获取JSON数据,但显示在XCode调试区域中

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

Hi I am building an application for iOS using Unity3D. 嗨,我正在使用Unity3D为iOS构建应用程序。 I am using UnityWebRequest to fetch data from my server (POST request). 我正在使用UnityWebRequest从服务器获取数据(POST请求)。 It works in my Unity Editor but not on my iPhone. 它可以在我的Unity编辑器中工作,但不能在iPhone上工作。 However, I can actually see the JSON data I want in the debugging window in XCode, which is below, 但是,实际上我可以在下面的XCode的调试窗口中看到我想要的JSON数据,

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? 因此,我的JSON数据正确显示在调试器信息中,但是为什么我无法从代码中获取它呢? Like string data = MY_JSON_DATA and let me to parse? 像字符串数据= MY_JSON_DATA一样让我解析吗?

I have checked ATS and this answer but it seems not work. 我已经检查了ATS此答案,但似乎无法正常工作。 Am I on the correct direction? 我的方向正确吗?

UPDATE: My Unity is 5.3.4p6, XCode: 7.3.1, iOS: 9.3 更新:我的Unity是5.3.4p6,XCode:7.3.1,iOS:9.3

UPDATE2: JSON API: Newtonsoft.JSON, WebRequest: UnityWebRequest 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. 未处理的异常:System.NotSupportedException:/Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System.Reflection.Emit/DynamicMethod.cpp(26):不支持的内部调用IL2CPP:DynamicMethod :: destroy_dynamic_method-不支持System.Reflection.Emit。

The IL2CPP transpiler works ahead-of-time (AOT) only. IL2CPP编译器只能提前(AOT)工作。 So it cannot create code at runtime, hence, System.Reflection.Emit is not supported as the error message indicates. 因此它无法在运行时创建代码,因此,错误消息表明不支持System.Reflection.Emit。

Some JSON utilities emit code at runtime, but many have an AOT-friendly mode that does not. 一些JSON实用程序会在运行时发出代码,但是许多实用程序都具有AOT友好模式,而没有。 In this case, the workaround "works" because the JSON utility that is used now is AOT-friendly. 在这种情况下,解决方法“行得通”,因为现在使用的JSON实用程序对AOT友好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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