I have been running into this error since I imported some PNGs for a system bar icon. I was successfully using xattr -cr MyApp.app in the location indicated by the error, but now I can't even do that - Terminal insists the directory structure doesn't exist, even though I can see it in Finder. I also have tried cleaning my build, and nuking the build folder in DerivedData, with no luck. I ran xattr on the entire DerivedData folder, just to be sure I got the package.
My project builds fine. It's just the codesigning that's failing.
Complete error is below.
CodeSign /.../InstallationBuildProductsLocation/Applications/MyApp.app (in target: MyApp)
cd /.../
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
Signing Identity: "-"
/usr/bin/codesign --force --sign - --entitlements /.../Release/MyApp.build/MyApp.app.xcent /.../InstallationBuildProductsLocation/Applications/MyApp.app
/.../InstallationBuildProductsLocation/Applications/MyApp.app: resource fork, Finder information, or similar detritus not allowed
Command CodeSign failed with a nonzero exit code
Update: I think I figured it out. I had to strip the attributes from the PNGs in the source directory of my project files, not just in the .app package built by Xcode.
I navigated to the location in my project directory and just ran xattr -cr . to wipe the attributes, and xattr -lr . to verify it worked. Once I did that, I was able to build a new archive.