Xcode 4 的隐藏功能

发布于 2024-10-25 03:45:00 字数 237 浏览 3 评论 0原文

现在 Xcode 4 已正式发布,是时候跟进我之前的问题了:Xcode 的隐藏功能

那么它们是什么?那些隐藏的 Xcode 4 小提示和信息是什么?您离不开的小贴士?

请将您的提示限制为那些新的且特定于 Xcode 4 的提示!

Now that Xcode 4 is officially released it's time for a follow up to my previous question: Hidden Features of Xcode

So what are they? What are those hidden little Xcode 4 hints & tips that you can't live without?

Please limit your tips to those that are new and specific to Xcode 4!

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

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

发布评论

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

评论(23

眼眸印温柔 2024-11-01 03:45:00

如果您希望代码看起来和运行时一样好,那么您无疑使用了 #pragma mark -#pragma mark 来提供良好的视觉分组在 Xcode 类下拉列表中。 Xcode 4 现在将它们组合成一个#pragma mark -

有关编译指示标记的更多信息

Xcode 杂注标记

If you like your code to look as good as it runs, you've undoubtedly used #pragma mark - and #pragma mark <name> to provide a nice visual grouping in the Xcode class dropdown list. Xcode 4 now combines these into a single #pragma mark - <name>.

More on pragma mark.

Xcode pragma mark

硪扪都還晓 2024-11-01 03:45:00
  • shift-cmd-opt 单击一个符号可以让您准确地告诉 Xcode 您在 UI 中的哪个位置想要打开导航到的文件。

  • cmd-ret 使版本编辑器/助手(右侧窗格)消失

  • shift-cmd-Y 隐藏调试器

  • cmd-0 隐藏导航器(左窗格)

  • cmd -[1..n] 在左侧导航器之间切换

  • cmd-opt-[1..n] 在实用程序之间切换(通常在右侧)

  • ctrl-[1..n]在编辑器中各个相关文件之间切换

总体而言,Xcode 4 尝试使热键保持一致。 Cmd 用于主线命令。添加修饰符适用于专注于某一特定子功能的类似命令。

(这些只是我想到的四个我经常使用的最受关注的快捷方式!我确信随着时间的推移,随着我的工作流程被重构为新的热点,它会发生变化。)

  • shift-cmd-opt click on a symbol lets you tell Xcode exactly where in the UI you want the navigated-to file to open.

  • cmd-ret makes the version editor / assistant (the right hand pane) go away

  • shift-cmd-Y to hide the debugger

  • cmd-0 to hide the navigator (left pane)

  • cmd-[1..n] switch between navigators on left

  • cmd-opt-[1..n] switch between utilities (thing generally on right)

  • ctrl-[1..n] switch between various related files in the editor

Overall, Xcode 4 tries to keep things consistent w/the hot keys. Cmd is for mainline commands. Adding modifiers is for analogous commands focused on one particular sub-feature.

(These are just the four that come to mind as the my most pounded upon shortcuts that I'm using constantly! I'm sure it'll change over time as my workflow is refactored into the new hotness.)

入画浅相思 2024-11-01 03:45:00

Xcode 4 添加了新的“代码片段”功能,可通过“查看”>“代码片段”访问。公用事业>代码片段库。要添加新的代码片段,请在编辑器视图中选择一些文本并将其拖到代码片段库中。您可以拖出一个代码片段并将其放入代码中来使用它,或者更方便地为其分配一个完成快捷方式。

当您输入这一系列字母时,它会在您输入代码时自动显示在代码完成弹出菜单中。例如,在许多其他内容中,我设置了一个片段,以便输入“svk”将扩展为 setValue:<#value#> forKey:<#key#>。这可以节省大量的打字和/或在自动完成菜单中查找您最常使用的方法和其他代码表达式的时间。 Xcode 附带了一堆内置的代码片段,它们也非常方便。

Xcode 4 adds a new "Code Snippets" feature, accessible via View > Utilities > Code Snippet Library. To add a new code snippet, select some text in the editor view and drag it into the snippet library. You can either drag a snippet out and drop it in your code to use it, or, much more conveniently, assign a completion shortcut to it.

When you type in that series of letters, it will automatically show up in the code completion pop-up menu as you type your code. For example, among many others, I have a snippet set up so that typing "svk" will expand to setValue:<#value#> forKey:<#key#>. This can save a lot of typing and/or fishing around in the autocompletion menu for the methods and other code expressions you use the most. Xcode ships with a bunch of built-in snippets that come in very handy as well.

°如果伤别离去 2024-11-01 03:45:00

我最常使用的新快捷方式:三指滑动(向上或向下)以交换对应项(在接口和实现文件之间)。不再有手部杂技了!

感谢 https://twitter.com/xctotd/status/48148271759241216

New shortcut I use most often: triple-finger swipe (up or down) to swap counterparts (between the interface and implementation files). No more hand acrobatics!

Thanks to https://twitter.com/xctotd/status/48148271759241216

我要还你自由 2024-11-01 03:45:00

Xcode 4 中的选项卡非常棒。每个选项卡都维护自己独立的布局,因此您可以拥有多个选项卡,其中包含不同的内容,并且每个选项卡都可以适当地布局。

我一直在使用 三种布局设置我的项目 - 一种用于项目对象,一种用于每个笔尖(显示所有者类的源代码),每个班级一个

这里有一个错误:从 4.0 开始,当您重新打开项目时,Xcode 将重置活动选项卡的状态(关闭任何助手)。解决方法是在关闭项目之前切换到没有 Xcode 助手的选项卡来关闭。我已将其归档为雷达号 9178441。

Tabs in Xcode 4 are awesome. Each one maintains its own separate layout, so you can have multiple tabs with different things in them and have each one lain out appropriately.

I've been setting up my projects with three layouts—one for the project object, one for each nib (showing the owner's class's sources), and one for each class.

There is one bug here: As of 4.0, Xcode will reset the state (turning off any Assistants) of the active tab when you reopen the project. The workaround is to switch to a tab with no Assistants for Xcode to close before you close the project. I have filed this as Radar number 9178441.

人疚 2024-11-01 03:45:00

shift-选项 - 单击组和文件列表项目导航器中的文件,或按住shift-<从跳转栏中选择文件时的kbd>选项。

你会得到一个流行音乐-从中选择打开文件的位置。 新的或现有的选项卡、新的或现有的拆分(助理)编辑器、新窗口 - 每个可能的选项都在那里。

shift-option-click on a file in the Groups and Files list Project Navigator, or hold shift-option while choosing a file from the Jump Bar.

You'll get a pop-over from which to pick where to open the file. New or existing tab, new or existing split (Assistant) editor, new window—every possible option is there.

凡尘雨 2024-11-01 03:45:00
  • ctrl-6 弹出跳转栏的文件内段(启用键盘控制的跳转到方法)

  • cmd-{/} 选择上一个/下一个选项卡

  • < kbd>cmd-J 导航到任何编辑器(但是为什么哦为什么不在它们之间循环使用 TAB?)

  • ctrl-6 pops down within-file segment of jump bar (enables keyboard-controlled jump to methods)

  • cmd-{/} select previous / next tab

  • cmd-J navigate to any editor (but why oh why doesn't TAB then cycle between them?)

诗笺 2024-11-01 03:45:00

编辑器快捷键

  • Cmd + Ctrl + 上/下 在之间跳转
    .h& .m 文件。
  • Cmd + Ctrl + 左/右 在上一个之间跳转
    已编辑的文件/下一个已编辑的文件。

布局快捷键

  • Cmd + 0 隐藏或显示导航器
  • Cmd + opt + 0 隐藏或显示检查器
  • Cmd + Shift + Y 隐藏或显示调试器控制台。

导航器快捷键

  • Cmd + 1 项目
  • Cmd + 2 符号
  • Cmd< /kbd> + 3 搜索
  • Cmd + 4 问题
  • Cmd + 5 调试
  • < kbd>Cmd + 6 断点
  • Cmd + 7 日志

选项卡切换&跳跃

  • Cmd + { 上一个选项卡
  • Cmd + } 下一个选项卡
  • Cmd + j 选择跳转位置
  • Shift + Option + ClickFile 选择打开文件位置
  • Cmd< /kbd> + Alt + 选项 + 单击 选择打开位置方法

检查器

  • Cmd + Opt + 1 文件检查器
  • Cmd + Opt + 2 快速帮助
  • < kbd>Cmd + Opt + 3 身份检查器
  • Cmd + Opt + 4< /kbd> 属性检查器
  • Cmd + Opt + 5 大小检查器
  • Cmd + Opt + 6 连接检查器

构建相关

  • Cmd + B 构建
  • Cmd + Shift + K 清理
  • Cmd + . 顶部

代码折叠

  • Cmd + Alt + 最小化当前方法/类/接口
  • Cmd + Alt + 展开当前方法/类/接口
  • Cmd + Alt + Shift + Left 最小化所有方法/类/接口
  • Cmd + Alt + Shift + 展开所有方法/类/接口

Editor ShortCuts

  • Cmd + Ctrl + up/down Jump between
    .h & .m Files.
  • Cmd + Ctrl + Left/Right Jump between Previous
    Edited Files/Next Edited files.

Layout Shortcuts

  • Cmd + 0 hide or show navigators
  • Cmd + opt + 0 hide or show inspectors
  • Cmd + Shift + Y hide or show debugger console.

Navigators Shortcuts

  • Cmd + 1 Project
  • Cmd + 2 Symbol
  • Cmd + 3 Search
  • Cmd + 4 Issue
  • Cmd + 5 Debug
  • Cmd + 6 BreakPoint
  • Cmd + 7 Log

Tab Switching & Jumping

  • Cmd + { Previous Tab
  • Cmd + } Next Tab
  • Cmd + j Select location to jump
  • Shift + Option + ClickFile Select location to open file
  • Cmd + Alt + Option + Click Select location to open Method

Inspectors

  • Cmd + Opt + 1 File Inspector
  • Cmd + Opt + 2 Quick Help
  • Cmd + Opt + 3 Identity Inspector
  • Cmd + Opt + 4 Attribute Inspector
  • Cmd + Opt + 5 Size inspector
  • Cmd + Opt + 6 Connection Inspector

Build Related

  • Cmd + B Build
  • Cmd + Shift + K Clean
  • Cmd + . top

Code Folding

  • Cmd + Alt + Left Minimize Current Method/Class/Interface
  • Cmd + Alt + Right Expand Current Method/Class/Interface
  • Cmd + Alt + Shift + Left Minimize All Method/Class/Interface
  • Cmd + Alt + Shift + Right Expand All Method/Class/Interface
简单爱 2024-11-01 03:45:00

这是第一个。标签! Xcode 4 用持久选项卡取代了 Xcode 3 有用但很少使用的“收藏夹栏”。这意味着您可以在选项卡栏中保留一组常用文档的工作集。

不完全是一个隐藏的功能 - 但选项卡是持久的这一事实可能很容易被忽视。

Here's the first. Tabs! Xcode 4 has replaced Xcode 3's useful but rarely used "favorites bar" with persistent tabs. This means you can keep a working set of commonly used documents in your tab bar.

Not exactly a hidden feature as such - but the fact that the tabs are persistent is perhaps easily missed.

悲歌长辞 2024-11-01 03:45:00

如果您在项目索引方面遇到任何问题(例如,自动完成中未显示符号),请打开“管理器”窗口,单击“项目”选项卡,然后使用“删除”按钮删除项目的派生数据。这将强制重建项目的索引,并丢弃任何构建的产品。

If you're having any sort of trouble with the indexing of your project (e.g. symbols not showing up in autocompletion), open the Organizer window, click the Projects tab, and use the "Delete" button to delete the derived data for your project. This will force a rebuild of the project's index, as well as tossing out any built products.

我的痛♀有谁懂 2024-11-01 03:45:00

在较小屏幕上工作的一些有用的热键是:

  • cmd-shift-y - 隐藏和显示控制台/调试区域

  • cmd-< kbd>0 - 隐藏和显示文件导航

Some useful hotkeys for working on smaller screens are:

  • cmd-shift-y - Hide and show the console/debug area

  • cmd-0 - Hide and show the file navigation

帅气称霸 2024-11-01 03:45:00

您现在可以将项目导航器中的组与磁盘上的文件夹相关联。之前一直困扰我的是,Xcode 3 文件视图可能无法代表磁盘上项目的实际结构。

创建一个新组,然后突出显示新组,打开文件检查器。在右侧的身份部分,“路径”正下方是一个小图标,单击此图标可打开文件浏览器对话框,允许您选择该组的目录。

文件检查器

You can now associate groups in the Project Navigator with folders on disk. It always bugged me before that the Xcode 3 file view may not represent the actual structure of the project on disk.

Create a new group, then with the new group highlighted, open the File Inspector. In the identity section on the right just below the 'Path' is a small icon, click this to open the file browser dialog allowing you to select the directory for this group.

File Inspector

不爱素颜 2024-11-01 03:45:00

如果按住 FN 键,则可以使用光标键扫描文档,而无需移动光标

If you hold the FN key then you can scan through your document with the cursorkeys, without moving the cursor

当梦初醒 2024-11-01 03:45:00

跳转栏:

如果你写外部函数:

// FIXME: A Bug
// TODO: Later
// ???: ???
// !!!: !!!
// MARK: This a mark

会喜欢:

您也可以搜索:

使用 Option 单击(同时按下 Shift,您可以选择另一个窗口),您可以看到一个对话框,让您指定文件应打开的位置:

源代码控制:

如果您使用 svn 或 git,放弃更改很容易:

界面生成器

在 xcode 4.2 中,您可以在此处跳转到界面生成器:

使用 Shift 单击 ui 对象,将显示其下所有对象的列表重点。

试试这个:
选择一个 ui 对象,按住 Option,然后将鼠标移到其他对象上。它会喜欢:

其他

热键:Shift+Command+O 快速打开

尝试:

#error message
#warning message

并阅读:
编写和编辑源代码

Jump bar:

if your write outside function:

// FIXME: A Bug
// TODO: Later
// ???: ???
// !!!: !!!
// MARK: This a mark

Will like:

Also you can search:

Click with Option(With Shift at the same time, you can choice another window), you can see a dialog letting you specify where the file should open:

Source control:

If you use svn or git, discard change is easy:

Interface buidler

In xcode 4.2, you can jump to interface builder here:

Click a ui object with Shift, it will show a list of all objects under the point.

Try this:
Select a ui object, hold Option, then move mouse over other objects. It will like:

Other

Hotkey: Shift+Command+O Open Quickly

Try:

#error message
#warning message

And read:
Writing and Editing Source Code

叹沉浮 2024-11-01 03:45:00

文本编辑器

  • 按住 Cmd 键单击类名称将转到该类的实现(或头文件)文件,按住 cmd 键单击对象将转到该位置对象被声明。
  • 按住 Alt 键单击将为您单击的对象打开一个文档弹出窗口。

添加框架:您不能简单地通过右键单击项目或组(如 Xcode 3 中)来完成此操作。您需要转到项目视图,选择目标并转到“构建阶段”选项卡。可以在“将二进制文件与库链接”部分下管理框架。

设置目标依赖项:与上面类似,在“构建阶段”选项卡的“目标依赖项”部分中。

确保您的档案安全 - 在安装 Xcode 4(从 3 开始)之前。您将失去它们(很可能),并因此失去象征崩溃日志的能力。

删除操作 - 请注意:“删除”(而不是“仅删除参考”)会直接从驱动器中删除文件。它不会进入垃圾箱,因此您无法恢复它。

Text Editor:

  • Cmd-clicking on a class name will take you to the implementation (or header) file of that class, cmd-clicking on an object will take you to where the object is declared.
  • Alt-clicking will open a documenation popup for the object you clicked on.

Adding frameworks: You cannot simply do this by right-clicking on the project or a group (like in Xcode 3). You need to go to the project view, select your target and go to "Build Phases" tab. Frameworks can be managed under the "Link Binary with Libraries" section.

Setting target dependencies: Similar to the above, in the "Target Dependencies" section of the "Build Phases" tab.

Keep your archives safe -prior to installing Xcode 4 (from 3). You will lose them (most likely) and with them lose your ability to symbolicate your crash logs.

Delete action-BEWARE: "Delete" (instead of "Remove Reference Only") directly erases the file from your drive. It doesn't go into the Trash, so you cannot recover it.

檐上三寸雪 2024-11-01 03:45:00

cmd-J 跳转到编辑器,但如果您打开了多个编辑器,您会得到一个包含所有打开的编辑器的覆盖层。您可以使用 cmd-cmd- 在打开的编辑器之间切换。

另外,如果您很难找到任何选项或属性,实用程序窗口可能是您最好的选择:

隐藏和显示实用程序: cmd-opt -0

这里通常隐藏一些不直观的东西:

  • 数据模型实体属性。
  • 数据模型属性
  • xib 属性

cmd-J jumps to the editor, but if you have more than one editor open you get an overlay that has all of the open editors. you can use cmd- and cmd- to switch between the open editors.

Also, if you are having a hard time finding an option or property for anything the utilites window is probably your best bet:

hide and show utilities: cmd-opt-0

Things that are commonly hidden here that aren't intuitive:

  • data model entity properties.
  • data model properties
  • xib properties
自此以后,行同陌路 2024-11-01 03:45:00
  • 不需要在 .h 文件中声明 IBAction - 方法。 &您可以直接在 Interface Builder 中连接它。

示例:

-(IBAction)btnLogInTapped:(id)sender {
    // place following method in .m file of your code. save file. Open the
    // .xib file of viewController
    // click on files owner
    // click on connection-inspector.
    // you can view your methods under "received actions"
}
  • 如果您要为其创建属性,则不需要声明变量

例子:

// a property declared in .h File of your view controller.
@property (nonatomic, retain) LogInVCtr *nxtLogInVCtr;

// synthesize above property in .m File
@synthesize nxtLogInVCtr;
// or
@synthesize nxtLogInVCtr = _nxtLogInVCtr;
// and you are done, you don't need to declare variable for it.
  • You don't need to declare IBAction - methods in .h File. & You can directly connect it in Interface Builder.

Example:

-(IBAction)btnLogInTapped:(id)sender {
    // place following method in .m file of your code. save file. Open the
    // .xib file of viewController
    // click on files owner
    // click on connection-inspector.
    // you can view your methods under "received actions"
}
  • You don't need to declare variables, if you are creating property for it.

Example:

// a property declared in .h File of your view controller.
@property (nonatomic, retain) LogInVCtr *nxtLogInVCtr;

// synthesize above property in .m File
@synthesize nxtLogInVCtr;
// or
@synthesize nxtLogInVCtr = _nxtLogInVCtr;
// and you are done, you don't need to declare variable for it.
梦里寻她 2024-11-01 03:45:00

我最喜欢的功能之一是“打开选项卡”行为偏好。如果您转到“首选项”中的“行为”,则可以将其设置为在运行开始时转到特定选项卡。您可以为该选项卡命名,例如“调试”,如果它不存在,Xcode4 将为您创建它,并在您开始调试时将您带到那里。您可以按照自己喜欢的方式配置此选项卡以进行调试会话,并且在关闭它后它将保持这种状态,因此每当您运行 Xcode4 时,都会在单独的选项卡中按照您想要的方式进行设置。您甚至可以将此选项卡撕成一个单独的窗口,在这种情况下,Xcode4 将在您每次开始运行时打开一个新的专门配置的“调试”窗口!此功能非常有用,因为它使您的常规代码编辑选项卡或窗口与日志和调试器窗格保持整洁。运行完成后,只需关闭“调试”窗口,即可返回干净的代码屏幕。

One of my favorites is the "Open Tab" behavior preference. If you go to "Behaviors" in Preferences, you can set it to go to a specific tab whenever a run starts. You can name the tab, something like "Debug" and Xcode4 will create it for you if it doesn't exist, and take you there when you start debugging. You can configure this tab just how you like it for debugging sessions, and it will stick that way after you close it, so whenever you do a run Xcode4 will be set up just how you want it, in a separate tab. You can even tear this tab off to a separate window, in which case Xcode4 will open a new specially configured "Debug" window each time you start a run! This feature is great because it keeps your regular code editing tab or window uncluttered with the log and debugger panes. Simply close the "Debug" window when you're done running and you can be back to your clean screen of code.

你是年少的欢喜 2024-11-01 03:45:00

在 XCode3 中,有一个“重命名项目”的选项。现在,您只需单击两次(第二次缓慢单击)即可重命名项目和名称。完成了。

In XCode3, There was an option for "Rename the Project". Now, you just need to click twice ( second click slowly ) to rename the project & Its done.

江城子 2024-11-01 03:45:00

限制并发构建操作的数量

这是一个(某种程度上)隐藏的首选项,允许您定义并发编译任务的数量:

defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4

在 IDE 中禁用索引

这个禁用代码感知索引,这可以在大型项目中节省大量资源:

defaults write com.apple.dt.XCode IDEIndexDisable 1

重新启用:

defaults delete com.apple.dt.XCode IDEIndexDisable

请注意,您应该退出 Xcode,根据需要设置首选项值,更改在重新启动 Xcode 时生效。

To Limit the Number of Concurrent Build Operations

This is a (somewhat) hidden preference which allows you to define the number of concurrent compile tasks:

defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4

To Disable Indexing in the IDE

This one disables code sense indexing, which can save a lot of resources in large projects:

defaults write com.apple.dt.XCode IDEIndexDisable 1

to reenable:

defaults delete com.apple.dt.XCode IDEIndexDisable

Note that you should quit Xcode, set the preference values as desired, changes take effect when you restart Xcode.

左秋 2024-11-01 03:45:00

如果您更喜欢使用在终端或任何其他外部编辑器上运行的 vim/emacs,您可以创建您的 Xcode 项目,添加文件等,然后切换到使用最适合您的编辑方式编辑所述文件;每当您将焦点切换到 xcode4 窗口时,修改后的文件将被重新加载(Xcode3 也是如此),您可以构建/运行您的应用程序。

If you prefer using vim/emacs running on, say, Terminal, or any other external editor, you can just create your xcode project, add files and whatnot and then switch to editing said files using whichever edit suits you best; whenever you switch focus to an xcode4 window, the modified files will be reloaded( was also the case with Xcode3 ) and you can build / run your application.

梦旅人picnic 2024-11-01 03:45:00

使用 XCode4 首选项的两种构建位置规范

  1. 目标指定的位置 - “构建”目录位于您的项目目录中。
  2. 派生数据中的位置(由 XCode 推荐,如屏幕截图所示)-“构建”目录位于指定的 DerivedData 位置下(例如,在我的情况下,/Users/digicorp/ Library/Developer/XCode/DerivedData

请查看以下屏幕截图。

在此处输入图像描述

在此输入图像描述

Two kinds of Build location specification using XCode4 Preferences.

  1. Location Specified By Targets - 'Build' Directory is located within your project directory.
  2. Location in Derived Data ( Recommended by XCode, as you can see in screen shot ) - 'Build' Directory is located under DerivedData location specified ( e.g. here in my case, /Users/digicorp/Library/Developer/XCode/DerivedData )

Please look at following screen shots.

enter image description here

enter image description here

心房的律动 2024-11-01 03:45:00

快速帮助

Ctrl + Option / Alt + f

查找快速帮助。例如,

@property (nonatomic, retain) NSString *strQuery;

我的文本光标位于 NSString &如果我按 Ctrl + Option + f 那么它将在检查器/实用程序中显示快速文档。

QUICK HELP

Ctrl + Option / Alt + f

Find the Quick help. For example,

@property (nonatomic, retain) NSString *strQuery;

My Text cursor is at NSString & if I press Ctrl + Option + f then It will show a quick documentation in the inspector/utilities.

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