creating archive fails with error «…-Prefix.pch» not found

I have a workspace with multiple targets.

Each target has its own prefix.pch file.
Prefix-Header is entered in Build Settings and Precompile Prefix Header is set to YES.

The app compiles and runs fine when I run it on my device.
There are no errors when I just build the app.

But when I try to archive it, I get a compile error saying:
Code Block
No such file or directory: '/Users/me/Library/Developer/Xcode/DerivedData/myApp-dcmvkatguqcxgjfyrqcunbsfuxcd/Build/Intermediates.noindex/ArchiveIntermediates/myAppTarget/PrecompiledHeaders/SharedPrecompiledHeaders/13524936819627194222/myAppTarget-Prefix.pch'

And indeed, when I open this folder on my hd, I can't see the pch-file. There are, however, similar files there:
Code Block
myAppTarget-Prefix.pch.d
myAppTarget-Prefix.pch.dia
myAppTarget-Prefix.pch.gch


I tried everything I found on SO and elsewhere, but nothing helped.

I have Cocoapods installed and use them in this project, but I don't think that error is related to that (they seem to compile fine).

XCode 12.4

Replies

Seems like I figured it out.

The culprit was a totally unrelated build-setting.

In Other C Flags my settings differed in debug and release.
I had $(inherited) in both of them, but in the release setting I additionally had -isystem - which apparently is already included in $(inherited). That caused a multitude of errors that ended with the prefix.pch not being copied...