Quick way to fix Xcode warnings - ios

I've been switching between versions of Swift in Xcode 6 and my project now has 220 warnings. Mostly minor code suggestions.
Is there an easy way in Xcode to run through all the warnings and use the "Fix-it" tool to auto correct it?
I would like to review each warning, then click a button to fix the warning, and then skip to next warning. Otherwise it's going to take me a few hours to manually get through each warning.

Your best bet is to use keyboard shortcuts. The default keyboard shortcut for Navigate > Jump to Next Issue is ⌘' (command-single-quote). If you press it, Xcode will jump to the next issue it knows about. If that issue has a Fix-it available, the Fix-it popover will appear automatically and you can press return to execute the Fix-it, or press ⌘' to leave the code unchanged and go to the next issue, or press escape to leave the code unchanged and stay on that issue.
You can also open the Issue Navigator (default shortcut: ⌘4). Then you can click on issues one-by-one. If you click on an issue with a Fix-it, Xcode will show the Fix-it popover and you can press return to execute the Fix-it.

Previous answer is best solution,before doing it you must Fix Validate project Settings (Update to recommended Settings).Suppose you decided to fix it last,it may again arises some new warnings.

control - option - command - f
⌃ ⌥ ⌘ f
Just type
⌘ Enter
afterward to adjust back to normal screens view.

Related

Xcode: How to temporarily hide yellow warnings from Issue Navigator

I'm working on a project (written by another developer...) with LOTS of yellow warnings.
During the build process, if there is a critical (red) error, the error keeps moving down beyond the bottom of the left pane, and it's always taking me some time until I can finally point the mouse at it and look at the error.
Is there a way of showing only the red (critical) errors?
Toggle the "!" button (Show only errors) at the bottom right corner of the Issues Navigator to hide Warnings (next to the results filter).
Go to the Project -> Your Project -> Search 'Warning'.
Then turn off warnings you don't want.
Xcode 11.7,
handle Apple Clang Warning Policies
image is more vivid.

Autolayout yellow warnings. Will it crash my app in run time

In storyboard , I am seeing a lot of yellow warning. Upon clicking the yellow warning , I get like update frame or update constraints. In the console it throws auto-layout warnings too. I just want to know whether it will crash my app because of this.enter image description here
Yellow warnings and auto-layout warnings in console are not related.
Yellow warnings means that what you see in IB is not what you will get at runtime according to current constraints. If you want to see what you will get you should click yellow warning and press "update frame". If you want to get at runtime what you currently see in IB you should press yellow warning and select "update constraint".
Runtime warnings in console means some constraints conflict at runtime. You should analyse the warning message to find what is the issue.
Most of the time it will not. But I suggest you to fix them all.
why not update all the frames, the difference Xcode complains about is not much, and NO it wont crash your application, BUT Xcode complains as there might be situations where your constraints wont work as per you set them.
Your Application will not crash weather it is a Yellow one or a Red one .
Xcode only means that the constrains you have kept may not work properly in different modes and resolutions .
You can simply fix it by simply clicking on update constraints,but result may not be what you expected.
So click on yellow arrow and read suggestion by xcode.

Xcode 5 indentation issue

I get indentation issues when I copy few lines and paste it. Xcode does not copy indentation properly or applies another indentations.
As shown in below images, I copied first function and pasted which is second function. Indentation are reapplied except for first line.
I played with Xcode indentation settings but could not solve it neither do I have any clue why this happens.
Below are 2 indentation settings I tried.
Do anybody see anything wrong in above settings?
In Xcode preferences, Key Bindings tab, redefine ⌘-V to "Paste and Preserve Formatting" and ⌘-option-shift-V to "Paste". Then ⌘-V will do "Paste and Preserve Formatting" which is what you want.
Try turning off Auto-Indentation. That way, Xcode doesn't remove formatting.
That was when i customized indentation in Swift and then get back to Obj-C. Nothing with changing preferences helped. Just fully restart xcode.
With cut and paste, you have to actually tell xcode to indent after the pasting.
⌘ A and then Control I.
The first one select the whole class contents (when the cursor is inside) and the second one indents it based on your indent preferences.
Hope this helps.
I just checked Xcode settings in another mac and made changes to match that and solved the issue. Sorry I don't remember what were they as it has been too long.

How to disable ARC for a single file in Xcode 5?

I recently downloaded Xcode 5, and it's now my primary IDE. However, I now need to disable Automatic Reference Counting for a single file in my project.
In Xcode 4, I went to the Build Phases tab under my target, and I could double click the on the right side of a row in the Compile Sources section, add -fno-objc-arc to the list of compiler flags, and be off.
In 5, however, the column seems to be unclickable:
So, how do I do this?
Well, I just tried and found that you must had dragged the window to a smaller width. You need to drag it back to show the Compiler Flag column:
To fix the real issue rather than a GUI issue, select the file and press ENTER, then you can add the -fno-objc-arc compiler flag.
You appear to be missing the right-hand column. On my install it looks like this:
Notice the 'Compiler Flags' column to the right of the 'Name' column.
Double-clicking anywhere on the row allows me to type into the flags as long as that column is on screen. Making my window sufficiently thin causes it to be invisible so the first thing I'd try is making your window super-wide, to see whether you can get a flags column.

How do I delete a breakpoint marker in xcode?

So my app is 100% done, however when I compile it in xcode the app loads up normal, but when I press the button, which is the apps main function, it encounters a thread breakpoint error and I'm not sure why.
When I run the app by itself in the simulator without xcode it runs perfect, the thread error only happens when I run it in xcode.
Thanks again for any help that can be provided!
Click on that dark blue arrow next to the "Play Sound" comment, and it will turn light blue (disabled). Or right click (or option-click) on the blue arrow and you have an option to remove the breakpoint.
Or select the breakpoint navigator ("View" - "Navigators" - "Show Breakpoint Navigator") and manage your breakpoints there.
See WWDC 2012 video Debugging in Xcode.
Your app stops when running in the debugger because you have set a breakpoint at that line. Delete or disable the breakpoint. There is nothing wrong here and there is no error. The debugger is doing exactly what you told it to do.
In XCode 9 the easiest way to delete breakpoint is to just left-click and drag it.

Resources