XCode:快速打开属性列表文件,例如 info.plist 作为源代码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35768948/
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 08:36:40  来源:igfitidea点击:

XCode: Quick open property list file e.g. info.plist as source code?

xcodeproperty-list

提问by Awsed

In Xcode you can "quick open" files by selecting File/Open Quickly. When I enter the file name of a plist file, then this file is opened as "Property List". But often I want to open the file as "Source Code". How can I quick open property list files as source code?

在 Xcode 中,您可以通过选择“快速打开”文件File/Open Quickly。当我输入 plist 文件的文件名时,该文件将作为“属性列表”打开。但我经常想将文件作为“源代码”打开。如何快速打开属性列表文件作为源代码?

回答by Awsed

The fastest method to open property lists in Xcode as source code is the following:

在 Xcode 中作为源代码打开属性列表的最快方法如下:

  • Press ?+?+oto get the Quick Open Dialog
  • Enter name of property list file e.g. "info.plist" and press "Enter"
  • Open "Version Editor" -> Property List File is shown as source code Opening Version Editor
  • 按下?+?+o以获取快速打开对话框
  • 输入属性列表文件的名称,例如“ info.plist”,然后按“Enter”
  • 打开“版本编辑器”-> 属性列表文件显示为源代码 打开版本编辑器

回答by Suz

Hmmm....I don't think you can, unless you set up the Open As > source code commands as a custom behavior with a key binding.

嗯......我不认为你可以,除非你将 Open As > source code 命令设置为带有键绑定的自定义行为。

Apple is discouraging opening plists as raw XML. Their guidance on how to deal with .plists is here

Apple 不鼓励以原始 XML 格式打开 plist。他们关于如何处理 .plist 的指导在这里

I was able to accomplish most of what I needed with that, especially after discovering the trick for showing the actual names of the keys:

我能够用它完成我需要的大部分工作,尤其是在发现了显示键的实际名称的技巧之后:

Important:The property list editor in Xcode displays human-readable strings (instead of the actual key name) for many keys by default. To display the actual key names as they appear in the Info.plist file, Control-click any of the keys in the editor window and enable the Show Raw Keys/Values item in the contextual menu.

重要提示:默认情况下,Xcode 中的属性列表编辑器会为许多键显示人类可读的字符串(而不是实际的键名)。要显示 Info.plist 文件中出现的实际键名,请按住 Control 键并单击编辑器窗口中的任意键并启用上下文菜单中的 Show Raw Keys/Values 项。

If you still need to see the .plist source, though, there are two ways:

但是,如果您仍然需要查看 .plist 源代码,有两种方法:

1) show the version editor. The source of the previous and current versions are shown side by side. where to select version editor (double arrow icon)

1) 显示版本编辑器。以前版本和当前版本的来源并排显示。 在哪里选择版本编辑器(双箭头图标)

2) use the file browser... (there should be a way to automate this with Xcode behaviors)

2)使用文件浏览器......(应该有一种方法可以使用Xcode行为自动执行此操作)

  • Hold the Control key while selecting the file in the file browser.
  • Select 'Open As..'
  • Select 'Source Code'
  • 在文件浏览器中选择文件时按住 Control 键。
  • 选择“打开为..”
  • 选择“源代码”

Screen shot of menu selections

菜单选择的屏幕截图

It's certainly not as fast as OpenQuickly, but it does work.

它当然不如 OpenQuickly 快,但它确实有效。