将运行脚本生成的文件添加到Xcode中的测试目标编译列表中 [英] Add a file generated by run script into the test target compilation list in Xcode
问题描述
我正在尝试将自动生成的文件(Mock.generated.swift
通过运行 swiftymocky generate
)添加到我的测试目标的编译源列表中.>
为此,我在编译源阶段之前添加了一个运行脚本阶段:
swiftymocky 生成
我也将生成的文件 Mock.generated.swift
拖到我的项目中,但将其从本地磁盘中删除.(我想通过脚本添加它,但我不知道如何添加.)然后该文件将在项目导航器中显示为红色,表示它已丢失.
然后当我构建测试目标时,我看到文件 Mock.generated.swift
回来了.但我仍然收到编译错误:
无法找到构建输入文件
那么我的尝试有什么问题?文件生成后可以动态添加文件到Compile Sources列表吗?
- 你的
run script
阶段应该在beforeCompile Sources
阶段 - 您需要将输出文件路径添加到
输出文件
.
这样做是让 Xcode 知道它应该在捕获文件结构之前等待此脚本完成.
I am trying to add an auto-generated file (Mock.generated.swift
by running swiftymocky generate
) to my Compile Sources list of my test target.
To do so, I added a Run Script phase before Compile Sources phase as:
swiftymocky generate
And I also dragged the generated file Mock.generated.swift
to my project but delete it from the local disk. (I want to add it by script but I don't know how.) Then the file will show as RED in the project navigator to indicate it's missing.
Then when I build the test target, I see the file Mock.generated.swift
is back. But I still get the compilation error:
Build input file cannot be found
So what's wrong with my attempt? Is it possible to dynamically add file to the Compile Sources list after the file is generated?
- your
run script
phase should be beforeCompile Sources
phase - you need to add output file paths to
Output Files
.
By doing this you're letting Xcode know that it should wait this script to be finished before capturing the file structure.
这篇关于将运行脚本生成的文件添加到Xcode中的测试目标编译列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!