Search code examples
xcodeclangclang-static-analyzer

Xcode disable `Value stored to '...' during its initialization is never read` analyzer warnings


I understand from this question that I can disable analyzer warnings by adding -Xanalyzer -analyzer-disable-all-checks to the compiler flags, however I do not wish to disable every warning, just this one warning. I understand that I should be able to figure out the specific warning from the output, but I cannot seem to find it:

/Users/.../file.m:1543:17: warning: Value stored to '...' during its initialization is never read CGFloat height = initialValue;

Obviously, I could resolve this by removing the initialValue, but I'm wondering if I could instead disable the warning.


Solution

  • I think what you are looking for is #pragma directive to silence a specific warning. Have a look at this answer:

    Is there a way to suppress warnings in Xcode?

    There are other solutions on the same page that also might work for you.