开发者

Xcode keyboard shortcut: jump to test file?

开发者 https://www.devze.com 2023-03-29 00:36 出处:网络
开发者_如何学JAVAIs there an Xcode keyboard shortcut to jump from MyObject.m to MyObjectTests.m, and vice versa? If so, what is it?I haven\'t found a way to do this. Feature request material I think.

开发者_如何学JAVAIs there an Xcode keyboard shortcut to jump from MyObject.m to MyObjectTests.m, and vice versa? If so, what is it?


I haven't found a way to do this. Feature request material I think.

At the bottom of "Project Navigator" you can type your filename in the search area to dynamically search for files you would be interested in. They will be filtered as you type.


If you always place your ClassTests next to its Class, you can use Control + 5 followed by Up/Down and Return. Three keystrokes. Not ideal but works.


Command + Shift + O works fairly well. It is an open quickly command, so you can type in the name of the file and get a list of:

  • MyObject.m
  • MyObject.h
  • MyObjectTests.m

It remembers what you typed last too, so next time you Command + Shift + O (in the same XCode instance) you can now down arrow twice and return to get from source to test file. Works in XCode 6.3 / 6.4; I am not sure about other versions.


If you already know the name of the test file where the relevant tests are located, then of course the above answers work well. But if you don't know where the tests are (such as when you inherited an old code base or it's been more than 2 days since you wrote it), there are two ways to do it.

  1. The keyboard shortcut ctrl-cmd-up will take you to the "generated interface" (a leftover from the objc days) for that file, but pressing it a second time will take you to the associated test file

  2. Use the assistant editor, which can be turned on either through the little menu in the top right corner, or through the keyboard shortcut ctrl-opt-cmd-enter. This will usually show the test file for an associated file (or vice versa if you're looking a test file!)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号