Home > Net >  Does Xcode have a way to jump to the "type declaration" for a variable?
Does Xcode have a way to jump to the "type declaration" for a variable?

Time:12-23

Assume I have the following swift code...

let myFooInstance = Utils.createFooInstance() // variable type is `Foo`

... and I want to quickly jump to the type declaration for myFooInstance (ie navigate to the source code for Foo).

In AppCode I can simply [shift] [cmd] click on the variable name to do so. Is there an analogous shortcut or otherwise efficient way to accomplish the same thing in Xcode?

The best I've been able to come up with:

  • [ctrl] [cmd] click to navigate to the function definition for createFooInstance(), which will indicate the return type Foo in its signature. Then [ctrl] [cmd] click on Foo to navigate to its definition.
  • [option] click on createFooInstance() to see the declaration window, which indicates Foo is the variable's type. While you can't click on the type name here (doing so takes you to documentation, not the source code), you can copy the name and [shift] [command] [o] paste it to navigate to the source code.

CodePudding user response:

Xcode has no equivalent of AppCode's Navigate > Type Declaration feature. I also sorely miss this feature.

  • Related