如何在Xcode中自动完成任务?

时间:2022-08-12 18:14:26

I'm building an app in Obj-C / Xcode and I'm running into some repetitive tasks. For example if I want to add an image resource to my project I just go through the same identical steps... only difference is the path to the resource.

我正在使用Obj-C / Xcode构建一个应用程序,我遇到了一些重复的任务。例如,如果我想将图像资源添加到我的项目中,我只需要执行相同的相同步骤...唯一的区别是资源的路径。

How can I automate these tasks?

如何自动执行这些任务?

Is there some sort of Xcode macro-recorder like in Photoshop and Excel?

在Photoshop和Excel中是否有某种Xcode宏录制器?

1 个解决方案

#1


There's definitely no macro recorder, but there are some tools you can use. First, there's Applescript, which is the most likely to be of use for this particular problem. I'm not promising it'll be easy, however. There isn't a rich collection of Applescripts for Xcode that I know of, so you'd need to dig through the Scripting Suite using Script Editor and see what's available.

绝对没有宏录制器,但您可以使用一些工具。首先,有Applescript,它最有可能用于这个特定的问题。然而,我不承诺它会很容易。我所知道的Xcode没有丰富的Applescripts集合,因此您需要使用脚本编辑器深入了解Scripting Suite并查看可用的内容。

For text things, there are User Scripts, which you can create from the script menu (it looks like a scroll). You can write perl, python, ruby, or whatever you like to process selected text and turn it into other text.

对于文本内容,有用户脚本,您可以从脚本菜单创建(它看起来像滚动)。您可以编写perl,python,ruby或任何您喜欢的内容来处理选定的文本并将其转换为其他文本。

You can also create text macros (Edit>Insert Text Macro).

您还可以创建文本宏(“编辑”>“插入文本宏”)。

Another major repetitive task is setting up your initial project. For that you can create new project templates to be set up as you like them. I have most of a walkthrough of that written up, and should have something posted on Cocoaphony this week or early next as part of my Building the Build System series.

另一个重要的重复任务是设置您的初始项目。为此,您可以根据需要创建新的项目模板。我已经完成了大部分内容的演练,本周或早些时候应该在Cocoaphony上发布一些内容作为构建系统系列的一部分。

#1


There's definitely no macro recorder, but there are some tools you can use. First, there's Applescript, which is the most likely to be of use for this particular problem. I'm not promising it'll be easy, however. There isn't a rich collection of Applescripts for Xcode that I know of, so you'd need to dig through the Scripting Suite using Script Editor and see what's available.

绝对没有宏录制器,但您可以使用一些工具。首先,有Applescript,它最有可能用于这个特定的问题。然而,我不承诺它会很容易。我所知道的Xcode没有丰富的Applescripts集合,因此您需要使用脚本编辑器深入了解Scripting Suite并查看可用的内容。

For text things, there are User Scripts, which you can create from the script menu (it looks like a scroll). You can write perl, python, ruby, or whatever you like to process selected text and turn it into other text.

对于文本内容,有用户脚本,您可以从脚本菜单创建(它看起来像滚动)。您可以编写perl,python,ruby或任何您喜欢的内容来处理选定的文本并将其转换为其他文本。

You can also create text macros (Edit>Insert Text Macro).

您还可以创建文本宏(“编辑”>“插入文本宏”)。

Another major repetitive task is setting up your initial project. For that you can create new project templates to be set up as you like them. I have most of a walkthrough of that written up, and should have something posted on Cocoaphony this week or early next as part of my Building the Build System series.

另一个重要的重复任务是设置您的初始项目。为此,您可以根据需要创建新的项目模板。我已经完成了大部分内容的演练,本周或早些时候应该在Cocoaphony上发布一些内容作为构建系统系列的一部分。