43

Yes I know that warnings are useful and should not be disabled and I usually correct all of them, but in XCode they mingle with my code and get on my nerves. I want to see warnings when I need them not all the time and in my face!

I'm ticked by the warnings displayed for Swift since they change the language constructs all the time! They have now obsoleted the for loop (I have never heard of a language that changes it's most basic constructs, but I suppose Apple could get away with anything) and now I get warnings embedded in my code every were.

It will be much better if the warnings would not expand in my code when I do a compile so I can expand them manually if I need them. Is this possible without disabling them in settings?

Cosmin
  • 6,623
  • 3
  • 26
  • 28
  • 2
    @gnasher729 Read the question. Also working on code wrote by others. – Cosmin May 04 '16 at 11:03
  • 11
    +1 cause it's the worst implementation of warnings I've ever seen, 1st they appear on top on the compiler result list **above errors** and distract the code read inlining everywhere. To make it worst the left dot is too small to click and most of the times you end up adding a breakpoint. Cream on top: automatic fix lead to new errors or warnings. **Xcode sucks!**. No mention to lack of backward compatibility of a new language no one needed. Apple, you hearing? – Jaime Agudo Dec 24 '16 at 13:24
  • The ability to ignore a specific warning would be great. Unfortunately it doesn't exist, you can only ignore all warnings or types of warnings as a group, both of which is a bad idea. – TheJeff Nov 12 '19 at 00:38

5 Answers5

100

I don't know if there are this option on Xcode 7, but in Xcode 8 just click at this icon on bottom at left side (blue icon) and it will filter only errors:

enter image description here

konstantin_doncov
  • 2,725
  • 4
  • 40
  • 100
Hernani Fernandes
  • 1,016
  • 1
  • 7
  • 4
20

First of all, it's a really bad idea: warnings exist for a reason, you really should check each of them.

There are few ways to try.

  1. Select Target -> select Build settings search as Warnings

Here you can change the Selected warnings to NO by selecting the dropdown.

enter image description here

  1. If you want to hide Objective c warnings follow the second image.

enter image description here

  1. If you want to hide Storyboard and XIBs warnings see the below image.

enter image description here

  1. If you want to hide Assets warning see the below image.

enter image description here

I hope this may help you :)

Ramesh_T
  • 1,251
  • 8
  • 19
  • This is very handy when the compiler is complaining about switch cases that are perfectly valid based upon adding and subtracting bits in a bit field. For example "case kStart | kAttribute : {" where kStart = 0b00010000 and kAttribute = 0b00001000 under the "enum ParsingState : Byte {" – Cerniuk May 21 '17 at 17:16
  • 1
    This was actually EXACTLY what I was hoping for... thank you! I have some warnings due to discarding the result of a method call that returns data (this is a short-lived R&D app and I'm playing with efficiency and memory usage). I don't want to ignore ALL the warnings, but ignoring the ones I've seen and chosen to ignore is nice to be able to do! – jrypkahauer Jun 13 '18 at 19:20
  • Where is 'Target'? – user124384 Dec 23 '18 at 03:40
9

Select your project and select your target and show Build Phases. Search the name of the file in which you want to hide, and you should see it listed in the Compile Sources phase. Double-click in the Compiler Flags column for that file and enter -w to turn off all warnings for that file. Hope it will help you.

Stanislav Pankevich
  • 11,044
  • 8
  • 69
  • 129
  • 1
    Added -w to some swift files but the warnings still apear after Clean + Build. – Cosmin May 04 '16 at 11:07
  • 2
    `-w` is Clang compiler flag so it only affects C/C++/Objective-C files. Looking at Swift compiler with `swiftc --help` there is option `-suppress-warnings Suppress all warnings`. Hope this helps. – Stanislav Pankevich Jun 24 '17 at 21:59
4

In Xcode 8, you can hide the warning's messages in the editor by

Editor - Issues - (Select) Errors only or completely show/hide errors and warnings using "Hide All Issues" or use shortcut Ctrl + Cmd + M

e

Nike Kov
  • 12,630
  • 8
  • 75
  • 122
0

For me, setting "Inhibit All Warning Flags" to "Yes" in Apple Clang - Warning Policies under the Build Settings tab (With All and Levels options highlighted) eliminated all warnings: "/* within block comment."

This is the image of the warnings on my XCode before the Inhibit All Warning Flags is set to "Yes"

(XCode Version 10.10 (10A255)).

AYO
  • 1