Bill David
Bill David

Reputation: 95

Add a file generated by run script into the test target compilation list in 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?

Upvotes: 2

Views: 1306

Answers (1)

Phil Dukhov
Phil Dukhov

Reputation: 88142

  1. your run script phase should be before Compile Sources phase
  2. 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.

enter image description here

Upvotes: 5

Related Questions