我的代码:

try
    {
        throw new System.ArgumentException("Parameter cannot be null", "original");
    }
    catch (Exception ex)
    {
        string exception = ex.ToString();
    }

但是正确的堆栈跟踪只能在Unity的编辑器中获取。
System.ArgumentException: Parameter cannot be null
Parameter name: original
at MyClassName (System.String message) [0x00026] in /Users/xxx/Documents/xxx/myPackageName/xxx/xxx/xxx/myClassName.cs:104

在设备堆栈跟踪如下:
System.ArgumentException: Parameter cannot be null
Parameter name: original
at MyClassName(System.String message) [0x00000] in <filename unknown>:0
at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <filename unknown>:0
at UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0
at UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0
at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <filename unknown>:0
at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00000] in <filename unknown>:0
at UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1].Invoke (.T1 handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <filename unknown>:0
at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) [0x00000] in <filename unknown>:0
at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, Boolean pressed, Boolean released) [0x00000] in <filename unknown>:0
at UnityEngine.EventSystems.EventSystem.Update () [0x00000] in <filename unknown>:0

为什么在Unity编辑器中,我在stacktrace上有文件名和行号,但是在此iOS设备上却没有?

这是一个开发版本

最佳答案

在Unity中制作ios构建时,请在构建对话框中检查Development Build。另外,在下拉菜单中,选择“在Xcode中运行作为调试”。在构建设置中,关闭“条形符号”复选框。

这将在版本中包括符号,并将允许报告文件名和行号。

08-16 22:32