Does Xcode have code navigation feature? - xcode

Does Xcode have a code navigation feature? Like unix's cscope type of tool which I can enter the name of a class and it will open the file for me? Or find out the caller of a particular method of a class? Or show the type hierarchy of a class?

command-shift-D (Xcode 4: command-shift-O) opens a Quick Open window where you can type a partial class name and hit enter to open the file. As far as more complex versions such as what Eclipse offers (method names, symbol names, etc), I don't believe anything like that is built into XCode.

In addition to the Quick Open window, there is the class browser. The class browser allows you to view the class hierarchy. The Class Browser can be found under the Project menu.

The "Jump To Definition" item is accessible through CMD + double click, which takes you directly to the relevant code
Also, you can "Jump To Documentation" by (Option or ALT) + double clicking on a class/method/property
Update:
Option + double click no longer takes you directly to documentation in Snow Leopard. Now it opens up a little documentation "bubble", with the option to jump to the documentation browser if needed.

If you Ctrl click a class name, method name or function name you will get a long meny where you can find the Jump to Definition item.

From XCode 4.4 upwards, you can find callers and callees by opening the "show related items" pop-up for a selected (highlighted) method:
Mark method in code (using your cursor or double click name)
Press Ctrl+1
Select "Callers" from the pop-up menu
You can also go View->Standard Editor->show related items or press the tiny button just left of the arrow buttons in the line just above the editor window (where it shows your currently selected file and method).

Also: select an identifier, right-click on it, and choose Find in Project > As Symbol (or Find in Project and choose Symbol as the search type) shows all symbolic uses, that is, declarations, definitions, and call sites.

There should opens up something like an element preview window or bubble when the user point to a method or item. The "Jump to Definition" change the users focus and take 2 steps to go to the target.
The relation window and context window in Source Insight is a good example,but I can't find them in Xcode and other dev tools for the mac.
By the way,the context window should have multiple layers to trace a deep referenced method like the split window in Xcode, not only one layer in the source insight.

Related

manual option is not showing in Xcode 11 assistant editor and how to add IBOutlet?

I recently updated to Xcode 11 and some of its user interface changed. in older version of Xcode there was options of accessing files in assistant editor using automatic or manual. but in this version of Xcode I can't see any manual option in assistant editor. so I am not able to add IBOutlet and IBAction methods to particular storyboard.
so can anyone tell me how to add these actions and outlets, that would be great help. thanks
By pressing the above button, Xcode will split the view and allow you to select a custom file using the file tree at the top.
You are correct.
The Manual option is no longer visible. You can still achieve the same result by doing a quick open using Cmd+Shift+O then type the name of any file you want to open. Press the Alt key and the file will open in the Assistant Editor Window.
As others have noted the new add editor button allows you to add new editors and open files into them. You could file a bug report but you may want to consider that you're likely to get a "works as designed" type of reply.
You can always change or add new keyboard shortcuts to get the behavior you want by viewing the preferences key bindings area and search for the command you want to shortcut.
Note
You can still ctrl+drag from storyboard to the class by the Adjust
Editor button in the upper right of the storyboard. Then just select
Assistant Editor on the list. After which you can make IBOutlets/IBActions.
open your storyboard, hold option key and select the file you want
In the documentation outline of storyboard, try to choose the "correct" item, which you want to set up outlet connections. Say you want to set up an outlet connection for cell of table/collection view.
View Controller > Collection View > Cell > Content View > Image View.
Try to select Cell, "Content View" or "Image View", then check the jump bar of assistant editor, you're probably able to switch to the .swift file you want.
Reference

How do I quickly access the interface version of my swift file in Xcode?

Since Swift files don't have a header, it can quickly get cluttered and hard to see just the public and internal methods that represent the interface of that file/class.
Xcode actually generates an interface file that can be found by clicking the Assistant Editor, then selecting the Counterparts type and you'll see the MySwiftFile.swift (Interface) file that you can check out.
Does anyone know an easier way to access this interface file? Maybe with a shortcut? I can't seem to find it using Cmd+Shift+O or other means.
Click the assistant editor (use the shortcut Cmd+Option+Enter to show the editor) and thereafter use Ctrl+Cmd+→ or ← to navigate to your .swift interface file in the assistant window. It's not an immediate short-cut, but possibly better than navigation by clicks/mouse/touchpad.
Open generated interface: Cmd+Ctrl+↑
Go back: Cmd+Ctrl+←
In no way, except for menu selection "Navigate / Jump to Generated Interface"
Xcode cannot assign key binding to "Jump to Generated Interface"
Allow to switch between Swift generated interface and original source via shortcut
It turns out there is a work-around for this.
System Preferences -> Keyboard -> Shortcuts -> App Shortcuts
Hit "+", select Xcode as the application, "Jump to Generated Interface" as the menu title, and then select your keyboard shortcut.

Xcode quickly jump to Action associated with a Control

Is there a quick way to jump to an action associated with a control.
Say there is a button on a XIB file that has an associated action. The way to find the code associated with this is rather tedious. Is there a short cut that can quickly jump to the code.
I am spoiled by Visual Studio - double click on a button and it takes you to it's handler
The fastest way I know to at least get quickly to the source file in which the action resides is the following:
select the button in the UI editor
hit ctrl+1 (this will open the “Related Files” drop down)
navigate to the “Sent Actions” sub-menu, e.g. via s, enter
select the relevant class (I think in this case there can only be one, so just hit enter again)
Once you are in the class, the action should be easy to find. If that's not the case, because your source file is so big, type ctrl+6 to open the “Document Items” drop down and start typing the name of the action. Once you see the action, select it via keyboard or mouse.
If you often don't know the name of the action, you will have to look it up before navigating to the class, e.g. by right clicking on the button.
I would advise to use ^+⎇+⌘+Enter to get to referenced code file. There you can search for #IBActions or #Outlets. If a UIButton has a segue attached, this method won't help to find it.
To review a list of actions, segues and outlets you can select an object on the storyboard and press ⎇+⌘+7 to open Connections Inspector on the right pane.

How to view IOS documentation using Xcode?

Is there a shortcut i can use to display or search Obj-C API?
Say, i'd like to learn more about what IBAction does, i wonder if i can mouse over it and view documentation. Is there a way this can be enabled? A side bar possibly?
Please advise
Option-click a class name and a window will pop up with a description. Click the book icon and the help window will open to that class. Command click to view the h file.
Not that I know off, but you may see the source code at any time, and that has plenty of documentation on the comments.
Command + click on it, then click Show Quick Help
Also there's a keyboard shortcut for opening general documentation list.
Command + Shift +0 (Zero)
In Xcode 4, the Organizer window has a documentation section which can be accessed from the Right sidebar (Quick Help, which is part of the button group to enable the bottom bar (GDB by default) as well as the left sidebar (Class tree/etc) ) of the main Xcode window whenever you click on basically anything in the code (if its a custom method/variable it only tells you where it is defined). However, if it is something like IBAction it will pop up a brief definition as well as a link to open the previously mentioned organizer to the appropriate documentation page.
Within the Quick Help information, click Open in Developer Documentation to access Xcode documentation, which includes more thorough explanations and references to related functions.
You can also access Developer Documentation window from the Xcode Help menu.
Another option is by using the keyboard shortcut Command+Shift+0.

Visual Studio window which shows list of methods

In Visual Studio, is there a window which shows list of methods in the active class? A small window like the Solution Explorer would be great. In Eclipse, there is one.
There's a drop down just above the code window:
It's called Navigation bar and contains three drop downs: first drop down contains project, second type and third members (methods).
You can use the shortcut Ctrl + F2 (move focus to the project drop down) and press Tab twice (move focus to the third drop down) to focus it, down arrow will expand the list.
Full size image
I found how to turn the drop down on as shown in the first answer (#ChrisF):
Go to Options->Text Editor->(your language)
and tick "Navigation bar" in the display section.
Since Visual Studio 2012, you can view the outline ( fields and methods) in the solution explorer by expanding the node corresponding to your file .
Shortcut to Navigation Bar is Ctrl+F2. Takes you to the types dropdown first. Press tab to go to method dropdown, and then enter on a method to go to that one.
ReSharper has a 'ReSharper | Windows | File Structure' window, which is used for visualizing current code file structure.
Resharper has the File Structure window which is very similar to eclipse outline view. Originally answered in:
Visual Studio 2012: List of all Methods in class
Resharper help:
http://www.jetbrains.com/resharper/webhelp/Reference__Windows__File_Structure_Window.html
Despite it's an old question maybe this answer help you as helped me.
you can download codemaid extension from here : codemaid website
it has a lot of functionality that you may find in their website.
the one that is related to this question is code digging
Visualize and navigate through the contents of your C# and C++ files from a tree view hierarchy. Quickly switch between different sorting methods to get a better overview. Drag and drop to reorganize the code. See McCabe complexity scores and informative tool tips.
in other words it give you ability to see the methods and properties and also reorganize them just with drag and drop. it's my everyday use extension
There is no direct equivalent to the Outline View in Eclipse. The closest thing I've found is the Class View, which lists all classes and their members/methods. There is a search box at the top to narrow the selection.
In Visual Studio 2019, there is the "Go To Member" action located in Edit - Go To that is mapped by default to ALT+\. I think this was added in Visual Studio 2017.
This is what pops up which provides the desired functionality and a couple of options:
In Visual Studio 2015, View > Other Windows > Resource View. The keyboard shortcut is Ctrl+Shift+E. I find this cleaner than Class View. With Class View Windows you can filter methods/attributes based on access modifier (private/protected/public) etc.
A nice clean way to do this is to use the command View.SynchronizeClassView by entering it into the Command Window (View > Other Windows > Command Window or Ctrl+Alt+A) but there's no way to do it automatically.
Additionally, you can:
pin your Class view window
collapse the top pane (listing all the classes)
And now it feels just like the Visual Assist's feature "List Methods in Current File" (which also list members btw).
At the top of your text editor, you should have a dropdown that lists all the methods, properties etc in the current type; and it's clickable (even if those members are defined in other files - in which case they're greyed out but you can still navigate with them).
Also, if you use the Class Explorer (Ctrl+Alt+C) to navigate your project, then you'll get a full overview of all your types. However, there doesn't appear to be a setting in Tools/Options that allows you to track the active type in that window (there is for the solution explorer) - perhaps a macro or addin is in order...
Microsoft doesn't feel like implementing this useful tool, but if by chance you can have Visual Assist, you have it in VAssistX > Tools > VA Outline. The plugin is not free though.
In Visual Studio 2005 and 2008 you can try the Source Code Outliner Power Toy.
alt text http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=SourceCodeOutliner&DownloadId=3493
Do you mean the class view window (View->Class View, or Ctrl+W,C)?
You also have the intellisence popup-window
With Visual Studio 2010
You choose Tools->Settings->Expert Settings
On the left-bottom corner, you will see the tab "Class View" right next tab "Solution Explorer"
In the top area of "Class View" layout, you will see the list of class name, enum, struct, ...
In the bottom area of "Class View layout, you will see the list of member for these class, enum or struct
I have been using USysWare DPack since forever. It is very small and not intrusive so if all you want is a quick shortcut window showing list of methods of the current file you are using, it provides just that. Good thing is that the author is still active after more than 10 years just to keep providing the same features into latest VS release.
https://marketplace.visualstudio.com/items?itemName=SergeyM.DPack-16348
After installation, just use Alt + M to bring up the method list window. I prefer to show all members instead, but it's up to you.
In VS 2012, just go to View > Class View...then you get the Class View GUI in the main tab area. Now, drag this over to the side dock and you have the exact same layout as you would in Eclipse.
-e
My best way to do this is, that i open the Code Definition Window, under View -> Code Definition Window or press Ctrl + W,D .
And then i got it floated and i have the definitions of methods in separate windows.
Regards
grep -i " sub " filename.vb > methods.txt
grep -i " function " filename.vb >> methods.txt

Resources