Xcode debugger doesn't print objects and shows nil, when they aren't

后端 未结 15 1721
暖寄归人
暖寄归人 2020-12-02 05:09

Xcode shows an error when trying to print an object with po , but only for one project.

error: Couldn\'t mater

相关标签:
15条回答
  • 2020-12-02 05:53

    I just run into a similar problem: At one point suddenly the Xcode debugger printed out some object types especially NSStrings as (null) although they were initialized with a value. Printed out via

    NSLog(@"String value: %@", myString);
    

    the correct value for the object was shown.

    Confusing! Solving the problem was rather easy: I just shut down Xcode and restarted my computer. After I restarted Xcode everything works fine again :).

    0 讨论(0)
  • 2020-12-02 05:54

    It seems everyone has their own solution.

    For me, I use Objective-C and Swift at the same time.

    First of all, go to TARGETS -> Build Settings and search the code generation

    You’ll find Apple LLVM 6.0 and Swift Compiler

    Change their Optimization Level all to None, then Debug, you may find the value not nil

    Amazingly once you can see the value, you solve this problem permanently, then you can change the Optimization Level to it used to be.

    0 讨论(0)
  • 2020-12-02 05:56
    1. Delete Derived Data
    2. Quite Xcode / Restart
    3. Clean Project

    That's all it took for me.

    0 讨论(0)
  • 2020-12-02 05:57

    For me, Xcode was filtering out the debugger output. Make sure your output setting is Debugger Output or All Output

    0 讨论(0)
  • 2020-12-02 05:57

    The solutions here will also fix the bug where you see error: <EXPR>:1:1: error: use of unresolved identifier every time you try to po a variable.

    For me the solution was to go to Build Settings and search for Optimization Level and make sure each Debug setting was set to None.

    0 讨论(0)
  • 2020-12-02 06:00

    Make sure that Address Sanitizer is turned off in your Scheme settings. The Address Sanitizer does not work well with the debugger.

    1. Go to Edit Scheme (Product >> Scheme >> Edit Scheme), choose Run, and go to the Diagnostics tab.
    2. Make sure "Enable Address Sanitizer" is off.

    0 讨论(0)
提交回复
热议问题