运行 Xcode 中的脚本和构建阶段在哪里?

Where is the Run Script and Build Phase in Xcode?

要设置 Carthage,documentation 说您需要添加一个 运行 脚本。

On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script in which you specify your shell (ex: bin/sh), add the following contents to the script area below the shell:

/usr/local/bin/carthage copy-frameworks

and add the paths to the frameworks you want to use under “Input Files”, e.g.:

$(SRCROOT)/Carthage/Build/iOS/Box.framework
$(SRCROOT)/Carthage/Build/iOS/Result.framework
$(SRCROOT)/Carthage/Build/iOS/ReactiveCocoa.framework

This script works around an App Store submission bug triggered by universal binaries and ensures that necessary bitcode-related files and dSYMs are copied when archiving.

但是,我在构建设置搜索中找不到构建阶段选项卡或 运行 脚本。 Xcode 8 Release Notes 提及

Xcode 8 provides completely rewritten AppleScript support. A new scripting dictionary provides the ability to automate Xcode workflows.

这是否意味着没有更多 运行 脚本?我查看了 AppleScript,但老实说它看起来非常复杂。我是否需要学习 AppleScript 来添加我在 Xcode 中使用过的简单一行代码?

/usr/local/bin/carthage copy-frameworks

它还在那里。确保单击下图中红色标记的所有位置。

Carthage 维护者更新了 README,也有必要添加输出路径以防止有用的框架复制。我发布了名为 Carting 的简单脚本来自动执行这些步骤。

您可以配置不同的构建阶段以在构建目标时执行任务。

要查看构建阶段,请打开项目编辑器并单击构建阶段。要添加未出现在编辑器中的构建阶段,请单击“添加”按钮 (+) 并从弹出菜单中选择一个构建阶段。

项目编辑器

使用项目编辑器查看和编辑您的项目和目标设置,例如构建选项、目标体系结构和代码签名特征。在主 window 中,单击导航器区域中的文件图标 (),然后 select 下面的项目。项目编辑器出现在导航器的右侧。从弹出菜单中选择项目或目标,然后使用选项卡切换到不同类型的设置。

运行脚本:

运行在构建过程中使用指定的 shell 脚本。此脚本可以从目标引用构建设置,例如 $(SRCROOT),该目录包含目标的源文件。此构建阶段还允许您提供输入和输出文件的列表。当没有提供输入和输出文件时,脚本总是 运行s。当提供输入和输出文件时,脚本只有 运行s 如果它以前从未 运行 过,输入文件之一已更改,或者输出文件之一丢失。可以为所有构建或仅在安装构建期间启用此构建阶段,并且可以为每个目标添加多次。