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

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.

Related

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:

iOS - Shortcut for jumping to definition in Xcode 9?

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.

Xcode Swift code folding/collapse

I know we can use "Shift + Alt + Cmd + Left" to fold/collapse swift code in Xcode, but can anyone tell me how to fold/collapse for functions only? Not properties? Or any alternative way?
The default folding method does the job, but actually also hide very important information from us......
This is what I wanted!
Updates in Xcode 10:
Xcode 10 has increased support for code folding, including:
A new code folding ribbon showing all of the multi-line foldable blocks of code in the editor
A new style for folded code in the editor that allows you to edit lines with folded code
Support for folding any block of code enclosed in curly braces
Support for folding blocks of code from the folding ribbon, from structured selection, or from the
Menubar ► Editor ► Code Folding ► Fold menu item
Look at this snapshot:
Code folding was disabled in Xcode 9 beta 1, which 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 ⌘ (command) button in keyboard and move/hover mouse cursor on any (start or end) braces. It will automatically highlight, block area.
Keep (hold) ⌘ (command) 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 ⌘ (command) 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
Code folding options from Xcode Menu:
Menubar ► Editor ► Code Folding ► "Here is list of code folding options"
Here is ref snapshot:
Same options from Xcode Short-cut list:
Menubar ► Xcode ► Preferences ► Key Bindings ► "Here is list of code folding short-keys"
Another way to do this would be as below.
Go to Xcode preferences (command + ,)
Select the text editing tab
Check code folding ribbon
Now when you look at your code you should be able to see this :
When you bring your mouse over the folding ribbon you should see a small arrow that can be used to fold code blocks (functions, if-else, loops, etc)
Hope this helps!
As of now there is no option to fold only functions in you class, we may expect these features in future release of Xcode. To fold specific function you can use alt + command + left_arrow after placing the cursor in function starting line. Use alt + command + right_arrow for unfold folded function.
Code Ribbons at the rescue for SwiftUI
It is a great feature to have. It seems too few developers know about this. Especially when writing code in SwiftUI, I like to see that my code works before refactoring it into separate views.
Folding is a great tool to have.
Here an example in Xcode 12. It is not active by default but you need too check the box "Code Folding Ribbon" in the preferences:
and you can fold nested views as deep as you like, with animation:
you can always go to Symbol Navigator, cmd+2 and enjoy list of all your declarations that swift has organized.
However, if this doesn't satisfy you, and you require to have better control over your functions I recommend you to use function protocols, they work somewhat similar to header files in C. you can find out more about function prototypes in(https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Protocols.html#//apple_ref/doc/uid/TP40014097-CH25-ID267)

XCode 7: code editor in "full screen" mode shortcut

There is a shortcut in XCode to make the code editor (or at least, the current focused window panel) full screen*? In Netbeans, this functionality is achieved with shift+esc: the focused panel expands, hiding other panels.
Thanks in advance.
*Not in the sense of "full screen" Mac OS feature, but the editor panel takes all the visible area, hiding other panels (like the Navigation panel, Property panel, etc).
You can create a new Behavior and assign a shortcut to it. At the top menu, select Xcode > Behaviors > Edit Behaviors...:
In the screenshot, I assigned it a shortcut key of Cmd + Esc but you can choose anything you want.
As far as I know there is not one button to do it all.
You can double click on the file and it will open a new editor window with just the text.
These three combinations will close each of the major three panels:
Command + 0 - Hide/show the Navigator
Shift + Command + Y - Hide/Show the Debug area
Alt + Command + 0 - Hide/Show the Utilities
You can change these in XCode -> Preferences -> Key Bindings

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