Xcode 键盘快捷键:跳转到测试文件?

发布于 2024-11-30 09:04:40 字数 99 浏览 1 评论 0原文

是否有 Xcode 键盘快捷键可以从 MyObject.m 跳转到 MyObjectTests.m,反之亦然?如果是这样,那是什么?

Is there an Xcode keyboard shortcut to jump from MyObject.m to MyObjectTests.m, and vice versa? If so, what is it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

任性一次 2024-12-07 09:04:40

如果您已经知道相关测试所在的测试文件的名称,那么上述答案当然可以很好地工作。但是,如果您不知道测试在哪里(例如当您继承了旧代码库时或者距离编写代码已经超过 2 天),有两种方法可以实现。

  1. 键盘快捷键 ctrl-cmd-up 将带您进入该文件的“生成的界面”(objc 时代遗留下来的),但再次按下它将带您进入关联的测试文件

  2. 使用助理编辑器,可以通过右上角的小菜单或键盘快捷键 ctrl-opt-cmd-enter 打开它。这通常会显示关联文件的测试文件(如果您正在查找测试文件,反之亦然!)

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!)

压抑⊿情绪 2024-12-07 09:04:40

我还没有找到办法做到这一点。我认为功能请求材料。

在“项目导航器”底部,您可以在搜索区域中输入文件名,以动态搜索您感兴趣的文件。它们将在您输入时进行过滤。

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.

梦过后 2024-12-07 09:04:40

如果您始终将 ClassTests 放在其 Class 旁边,则可以使用 Control + 5 后跟 向上/向下返回。三个按键。不理想但有效。

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.

各自安好 2024-12-07 09:04:40

Command + Shift + O 效果相当好。这是一个快速打开的命令,因此您可以输入文件名并获取以下列表:

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

它也会记住您上次输入的内容,因此下次您命令 + Shift + O (在同一个 XCode 实例中)您现在可以向下箭头两次并返回以从源获取到测试文件。适用于 XCode 6.3 / 6.4;我不确定其他版本。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文