iOS - Shortcut for jumping to definition in Xcode 9? - ios

In previous Xcode version , I could jump to definition with simple
Cmd + click on that method/variable .
But in Xcode 9, I feel uncomfortable to jump to definition .
Does anyone has a better solution for jumping to definition in Xcode 9 ?
I am tired of selecting options from dropdown list.

Ashish and Ghulam's answers were great but it still kinda bugged me that things had changed and I couldn't jump to definition as before. Then I found this...
Xcode9Beta2-Preferences->Navigation->Command-click on Code:->Jump To Definition:

Solution 1:
Go to Xcode menu
Click on Preferences
Select Navigation Tab from Top
Select Command-click on Code
Change to "Jumps to Definition"
Solution 2:
Use
Ctrl + ⌘ + Left click

There is short cut displayed on drop down menu, just use-
1. Control, Command and left mouse button
OR
2. Command plus Right Mouse Click
instead of command left mouse button.

In Xcode 9 Beta, you can go definition by Cmd + Right Click

Standard hot key for jump to definition is ctrl+cmd+j. Set cursor to the class/method you are interested in and press this buttons to switch to declaration. Also you can try to press ctrl+opt+cmd+j. In this case definition will be opened in assistant editor

If dont like to use mouse click(I certainly don't like) you could use
Command + Ctrl + J

In Xcode 9 both of these work:
⌘ + Right Click
OR
⌘⌃ + Click

When I ⌘-click on a symbol in Xcode 9 I see
That means you have to ⌃⌘-click on the symbol to skip the popup.
Nevertheless there is even a keyboard shortcut:

I don't know how Cmd + Option + Left Click worked for you guys, but the shortcut (at least for me) was Cmd + Ctrl + Left Click.
I've tried on both Apple keyboard and MacBook keyboard and this is the one that did it.

In Xcode 9 Beta, it has been changed to Cmd + Ctrl + Left Click.

Solution to your question: Ctrl + ⌘ + Left click
Xcode >> Preference >> Key Bindings >> Here is list of all short cuts
of Xcode.

Deleting everything under the Derived data and re-opening Xcode fixed everything for me.

Related

Code folding not working in Xcode 9.0 beta 2

I use code folding frequently in Xcode. Recently I tried code folding in Xcode 9 beta with shortcut Command + alt + left arrow and nothing happened.
So I tried to do the same with editor option in menu bar but it seems like code folding option is disabled. How can enable code folding option in Xcode 9 and make it to work again like in Xcode 8 .
Code folding is working now, in Xcode 9 Beta5 according to beta release note: Resolved in Xcode 9 beta 5 – IDE
Here is how:
Press and hold ctrl (control) button in keyboard and move/hover mouse cursor on any (start or end) braces. It will automatically highlight, block area.
Keep (hold) ctrl (control) button in pressed condition and click on highlighted area. It will enable quick menu popover window with Fold option.
Select Fold from menu list. It will fold your code and shows 3 dots, folding/covering entire block.
Now, to again unfold your code block, release ctrl (control) button and click on 3 dots folding a block.
For easy understanding, look at this snapshot:
It's all keyboard short cuts are also working.
Fold ⌥ ⌘ ← option + command + left arrow
Unfold ⌥ ⌘ → option + command + right arrow
Unfold All ⌥ U option + U
Fold Methods & Functions ⌥ ⌘ ↑ option + command + up arrow
Unfold Methods & Functions ⌥ ⌘ ↓ option + command + down arrow
Fold Comment Blocks ⌃ ⇧ ⌘ ↑ control + shift + command + up
Unfold Comment Blocks ⌃ ⇧ ⌘ ↓ control + shift + command + down
Focus Follows Selection ⌃ ⌥ ⌘ F control + option + command + F
Fold All ⌘ ⌥ ⇧ ← command + option + shift + left
Unfold All ⌘ ⌥ ⇧ → command + option + shift + left
Here is ref snapshot:
See the release notes. Code folding is not yet supported in beta 3:
The source editor in this beta version of Xcode 9.0 doesn’t support code folding. (29396003).
According to a WWDC presentation, they've done a fairly major rewrite of the editor, so don't be surprised if it takes them a while to nail all this down.
And as with all beta software, I'd suggest reviewing the release notes carefully, as there are lots of open issues that are well documented there.
Code folding now works in beta 5.
In Xcode 9 build 9A235 the Code Folding does not always open the methods when clicking on the 3 dots. When this occurs you can click the method below the one you wish to open and this sometimes works. Apple should be embarassed for releasing such a half-baked feature. What's more, the boxes around the folded methods add no value and are simply additional, unnecessary, clutter.

Visual Studio for Mac how to collapse regions and methods

I couldn't find a way to collapse/expand regions and sections from Visual Studio for Mac.
If someone could share how to do that, it would be very useful.
You need to go to Preferences >> Text Editor >> General as on the image below and you will see Code Folding area.
You can check whatever you need and you will see code folding blocks in your code.
menu > help>
type "folding" ,
then move the mouse over list items.
Yes.. You can follow this key patterns to collapse and expand all the methods.
Shift + Option + Command + ArrowDown
Shift + ⌥ + ⌘ + ⬇
OR Follow the Image Screenshot:

Quick way to fix Xcode warnings

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.

What is the way to quick-switch between tabs in Xcode 4

I have opened many tabs while working on project. (new feature in Xcode 4).
But for switching from one tab to other tab, the only way I've found to do this is to use the mouse. Is there any way to switch between different tabs using keyboard shortcuts?
Shortcuts are:
CMD + SHIFT + } - Select Next tab
CMD + SHIFT + { - Select Previous tab
The default shortcuts are:
⌘ + SHIFT + { - Select Next Tab
⌘ + SHIFT + } - Select Previous Tab
But I prefer going to XCode -> Preferences -> Key bindings and changing them to:
CTRL + TAB - Select Next Tab
CTRL + SHIFT + TAB - Select Previous Tab
...so they work the same as in Chrome or Safari.
If the shortcuts don't work (because of language, for example), you can define custom shortcut:
XCode -> Preferences -> Key bindings
Make sure that "all" is selected
Define shortcuts for "Select Previous Tab" and "Select Next Tab"
I used cmd+pageup and cmd+pagedown, didn't generate any conflicts.
XCode Windows menu option shows it as ⌘+ } or ⌘+ { but I think it is a bug since ⌘+ {/} is used for increase indent or decrease indent.
The correct sequence is ⌘+ shift + } or {.
I perfer using BetterTouchTool to switch between tabs(include Chrome, Safari, Finder, Xcode, sublimeText and so on).
BetterTouchTool is a free software.
Just set TipTap Left and TipTap Right to cmd+shift+{ and cmd+shift+}.
And than, you can use trackpads with tiptap to switch between taps.
Here is my configuration:
Hope you will like it.

Xcode 4 keyboard shortcut to switch build target destination

Is there a keyboard shortcut in Xcode 4 to switch the build target destination; that is, to switch from simulator to device and vice versa?
There is, is called Destination>select next destination. Go in the prefs in xcode and then in the key bindings tab, search for that, it will show what key it is set at.
For me, is cmd+alt+ctrl+] and [ to switch. Is quite useful, saves a few seconds.
In Xcode 4.6, the shortcut is ctrl+option+cmd+[ and ctrl+option+cmd+]
You can use ctrl + cmd + [ or ctrl + cmd + ] to select scheme, or use ctrl + cmd + [alt] [ or ctrl + cmd + [alt] ] to select product
Or you can just search in the preference panel of key bindings for more information
You can write applescript and bind it to some hotkey (using FastScripts for example - free up to ten bindings).
Next script will click for you on your scheme button in the Xcode toolbar:
tell application "System Events"
tell process "Xcode"
click ((pop up buttons of list 1 of group 2 of tool bar 1 of front window) whose description is "Active Run Destination")
end tell
end tell
then you can just use Up/Down to switch destination.
Note that you need to enable access for assistive devices under the SystemPreferences -> Accessibility
You can go to the edit scheme menu with cmd+< which is actually cmd+shift+.
You should know
Build: cmd+B
Run: cmd+R
Test: cmd+U
Profile: cmd+I
Analyze: shift+cmd+B
But there isn't a command just to switch between the iPhone simulator, iPad simulator, and all of your external.
I have a slightly different problem but it might help you as well.
I have only one physical device which always stays at the top.
Its super simple to select top list device as a target.
Do:
pops up the list for target devices
CTRL + SHIFT + 0
takes you to the first device
CMD + UPARROW
selects that device
SPACE
Apple Script goes:
tell application "Xcode" to activate
tell application "System Events"
tell process "Xcode"
keystroke "0" using {control down, shift down}
delay 0.55
keystroke (ASCII character 29)
delay 0.55
keystroke (ASCII character 30) using command down
delay 0.55
keystroke (ASCII character 32)
delay 0.55
keystroke "r" using command down
end tell
end tell
Riffing on off Comradsky, the answer is then:
Cmd+Shift+, then Tab then Up/Down
You can also option-click on the scheme in the title bar to directly open the settings for the scheme (whereas a normal click opens the context menu that displays a list of all the schemes).
Show Destinations
To bring up the list of destinations use ⤵︎
^ + Shift + 0

Resources