Xcode,默认窗口布局?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15021604/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:50:28  来源:igfitidea点击:

Xcode, default window layouts?

xcodedefaultpreferences

提问by Fattie

No-one has been able to answer this question.

没有人能够回答这个问题。

It would seem to be impossible to have XCode openthis way.

以这种方式打开XCode 似乎是不可能的。

However Youssef provided the most useful answer - so Youssef gets the points, thank you Youssef.

但是 Youssef 提供了最有用的答案 - 所以 Youssef 得到了分数,谢谢 Youssef。



Note for future readers .. the mac utility Moom is excellent for some, but not all, problems of this nature. Again it is not a total solution.

给未来读者的注意事项 .. mac 实用程序 Moom 非常适合解决某些(但不是全部)这种性质的问题。同样,这不是一个完整的解决方案。



Using the current up-to-date XCode,

使用当前最新的 XCode,

Whenever I OPEN a project in XCode (or start a new project),

每当我在 XCode 中打开一个项目(或开始一个新项目),

it looks like this:

它看起来像这样:

enter image description here

在此处输入图片说明

However, I want it to look like this:

但是,我希望它看起来像这样:

enter image description here

在此处输入图片说明

Again that's when I OPEN a project.

这也是我打开一个项目的时候。

Is there any way to achieve this? Thanks.

有没有办法实现这一目标?谢谢。

回答by Youssef

Go to Xcode (in the top menu bar) --> Preferences...

转到 Xcode(在顶部菜单栏中)--> 首选项...

Switch to the Behaviorstab and modify what you want in the Runningsection

切换到Behaviors选项卡并在Running部分修改您想要的内容

You'll get something like this: enter image description here

你会得到这样的东西: 在此处输入图片说明

You can choose to show/hide what you need, and specify the default behavior

您可以选择显示/隐藏您需要的内容,并指定默认行为

Cheers

干杯

EDIT:

编辑:

After understanding what you need, I will modify my answer.

了解您的需求后,我将修改我的答案。

There is no way to force XCode to automatically enter a behavior at startup.

无法强制 XCode 在启动时自动输入行为。

The best you can do is to create a custom behavior and give it a keyboard shortcut. And when you start XCode just use the keyboard shortcut to enter the desired behavior.

您能做的最好的事情是创建自定义行为并为其提供键盘快捷键。当您启动 XCode 时,只需使用键盘快捷键输入所需的行为即可。

This is how it is done:

这是如何完成的:

In the behaviors tab (above) click on the + sign at the bottom

在行为选项卡(上方)中,单击底部的 + 号

tut1

啧啧

Then enter the desired name of this behavior (Maybe StartupBehavior) tut2

然后输入此行为的所需名称(Maybe StartupBehavior) 啧啧2

Click on the left button to modify the shortcut key. My preferred shortcut key is Command+ `(the button to the left of the '1' key). This is because it will not override any other command and it is easy to click.

点击左键修改快捷键。我首选的快捷键是Command+ `('1' 键左侧的按钮)。这是因为它不会覆盖任何其他命令,而且很容易点击。

Note: you can specify any shortcut you like and dont be afraid to override one that already exists if you don't use it.

注意:您可以指定任何您喜欢的快捷方式,如果您不使用它,不要害怕覆盖已经存在的快捷方式。

Now you need to configure your behavior the way you like it

现在你需要按照你喜欢的方式配置你的行为

Tut4Close the preference windows.

图 4关闭首选项窗口。

Now everytime you start XCode just use the shortcut key you specified (Command+ `in my case) to quickly load your behavior

现在每次启动 XCode 时,只需使用您指定的快捷键(在我的情况下为Command+ `)即可快速加载您的行为

Note:

笔记:

If you dont like keyboard shortcuts you can also load your behavior by going to Xcode(menu bar) --> Behaviors--> Select your behavior Tut5

如果您不喜欢键盘快捷键,您还可以通过转到Xcode(菜单栏)-->行为--> 选择您的行为来加载您的行为 图 5

That is the quickest way you can achieve what you want. I dont think you will be able to force Xcode to run your behavior automatically on startup.

这是实现您想要的最快方式。我认为您无法强制 Xcode 在启动时自动运行您的行为。

Hope it helped.

希望它有所帮助。

Cheers

干杯

回答by blub

  1. (not really default layout, you have to hit at least 2 keys simultaneously once XCode is open)You could set up a behavior for "Build->Starts" and hit "CMD + B" after opening XCode / any Project. This way it will 1. change to your Layout even if there are any errors and Build fails and 2. you don't have to Stop it again.

    As already said, it's not a default layout, but I like to let the compiler run through projects of other people at the beginning anyway.

    XCode Preferences


  2. You could search for some Keys in XCodes preference file in ~/Library/Preferences/com.apple.Xcode.plistas already suggested in my comment, I'm not experienced enough to know which are the right ones, sorry.


  3. Wrap the .xcodeproj File opening in an application. E.g. in no way "clean", but anyway:

    1. Set up an XCode behavior like in option 1
    2. Open Automator, choose Application, drag "open Finder Items" and "run AppleScript" inside. Automator

      on run {input, parameters}
      
      set frontmostAppName to name of (info for (path to frontmost application))
      repeat while frontmostAppName is not "XCode.app"
          set frontmostAppName to name of (info for (path to frontmost application))
          delay 0.5
      end repeat
      try
          tell application "System Events" to keystroke "b" using {command down} --simulates CMD + B
      end try
      return input
      
      end run
      
    3. Insert some applescript like the above and save the Automator application.

    4. RightClick -> getInfo on any .xcodeproj File in Finder/on Desktop, in "open with" select your new Automator app, click add and back in the info panel -> check "Change All"
  1. (不是真正的默认布局,一旦 XCode 打开,您必须同时按下至少 2 个键)您可以为“Build->Starts”设置行为,并在打开 XCode/任何项目后点击“CMD + B”。这样,它会 1. 更改为您的布局,即使有任何错误并且构建失败,并且 2. 您不必再次停止它。

    如前所述,它不是默认布局,但无论如何我喜欢让编译器在开始时运行其他人的项目。

    XCode 首选项


  2. 您可以~/Library/Preferences/com.apple.Xcode.plist在我的评论中已经建议的XCodes 首选项文件中搜索一些键 ,我没有足够的经验来知道哪些是正确的,抱歉。


  3. 包装在应用程序中打开的 .xcodeproj 文件。例如绝不是“干净”,但无论如何:

    1. 像选项 1 一样设置 XCode 行为
    2. 打开 Automator,选择应用程序,将“打开 Finder 项目”和“运行 AppleScript”拖到里面。 自动机

      on run {input, parameters}
      
      set frontmostAppName to name of (info for (path to frontmost application))
      repeat while frontmostAppName is not "XCode.app"
          set frontmostAppName to name of (info for (path to frontmost application))
          delay 0.5
      end repeat
      try
          tell application "System Events" to keystroke "b" using {command down} --simulates CMD + B
      end try
      return input
      
      end run
      
    3. 像上面一样插入一些applescript 并保存Automator 应用程序。

    4. 右键单击 -> 在 Finder/桌面上的任何 .xcodeproj 文件上获取信息,在“打开方式”中选择您的新 Automator 应用程序,单击添加并返回信息面板 -> 选中“全部更改”

You can obviously create a new Behavior instead of using Build->starts, assign a different Hotkey in XCode and script e.g. tell application "System Events" to keystroke "i" using {command down, control down, shift down, alt down}, optimize the applescript somehow or do everything via a real cocoa app if you want

显然,您可以创建一个新的行为而不是使用 Build->starts,在 XCode 和脚本中分配不同的热键,例如 tell application "System Events" to keystroke "i" using {command down, control down, shift down, alt down},以某种方式优化 applescript 或者如果您愿意,可以通过真正的可可应用程序完成所有操作

回答by justin

Well, you may be able to approach it using preconfigured xcuserstate files nested in your project templates' default workspace directory, but that is going to be a pain to tweak and maintain. I'm not even sure it would work.

好吧,您可以使用嵌套在项目模板的默认工作区目录中的预配置 xcuserstate 文件来处理它,但这将很难调整和维护。我什至不确定它会起作用。

I would personally just approach it by using Behaviors.

我个人会通过使用行为来解决它。

So:

所以:

  • 1) create a Behavior
  • 2) Give it a convenient key binding
  • 3) Then define the Behavior. For example:
  • 1)创建行为
  • 2)给它一个方便的键绑定
  • 3)然后定义行为。例如:

ASCII Behavior Editor:

ASCII 行为编辑器:

...

√ Show *Debugger* with *Console View*

√ *Hide* utilities

...
...

√ Show *Debugger* with *Console View*

√ *Hide* utilities

...

That should do it. Just hit the assigned key command when you want to restore that display state, regardless of its initial state.

那应该这样做。无论其初始状态如何,当您想要恢复该显示状态时,只需点击指定的键盘命令即可。

Of course, you can do a few other things or all sorts of arbitrary stuff by running an external AppleScript (triggered with a Behavior's run script facility).

当然,您可以通过运行外部 AppleScript(由 Behavior 的运行脚本工具触发)来做一些其他的事情或各种任意的事情。