Xcode 13 gives me a hard time building my project which consists of targets with build phases that generate code.
E.g. one build phase generates the file Secrets+Generated.swift
by simply using a shell script that echoes some code into that file.
The build phase defines that file as an output file. No input file, no input file list and no output file list, as only that one file is created/modified.
Almost all the time when building the project, the build fails:
error: input file '[ProjectPath]/Secrets+Generated.swift' was modified during the build
error: input file '[ProjectPath]/Secrets+Generated.swift' was modified during the build
Command CompileSwiftSources failed with a nonzero exit code
Has anyone encountered that issue or knows what to do? I tried toggling the checkbox "Based on dependency analysis", but that didn't help. I didn't have that issue when using Xcode 12. Interesting to note is the duplicate error message despite having only one build phase generating that particular file.
Btw. I get the same problem when using code generation tools like swiftgen, Sourcery or Cuckoo.
Edit: Here are my build phases:
The three marked build phases all generate one such file. All of them fail occasionally. I do not know if that makes a difference, but these are defined for only one target (Notification Service Extension) which is a dependency of my main app target, so it gets triggered only once when I build the app.