Mine is an Obj-C MacOS X project with several targets, Running latest Xcode 12.5.1. Failing target is a normal Cocoa App.
It started failing with this exact error after I dragged an image file to the project (into Resources group/directory), added to the target and tried to build. I use this image resource programmatically. Failed again and again. Removing the image removed the problem.
I found the image file WAS NOT copied to the project repo, and the reference pointed to somewhere outside the repo. I deleted the reference from the project, copied the actual file into the project repository, re-added it to my project/group and target. Verified the reference was now inside the project repo (relative to group, with just the file name as a 'path').
Now it built OK.
I then dragged another image (this time I first copied it into my Resources group/directory) and sad to say - the problem resurfaced.
Reading other answers here, I saw the proposed build script: xattr -cr ~/Library/Developer/Xcode/DerivedData || echo Clear
So I started to suspect the actual image files had something about them that was not to Xcode's liking. so... a Quick Terminal shell:
mini-mac7:Resources $ ls -la@ total 392 drwxr-xr-x 5 mshneor staff 160 Jun 28 13:57 . drwxr-xr-x 12 mshneor staff 384 Jun 28 13:44 .. -rw-r--r--@ 1 mshneor staff 19688 Jun 28 13:44 MyPtShield.png com.apple.lastuseddate#PS 16 -rw-r--r--@ 1 mshneor staff 172435 Mar 16 2017 My-logo-reg-K.png com.apple.FinderInfo 32 com.apple.lastuseddate#PS 16 com.apple.quarantine 57 -rw-r--r--@ 1 mshneor staff 258 Jun 28 13:44 factoryDefaults.plist com.apple.lastuseddate#PS 16
And sure enough - both image files DO HAVE extra information and extended attributes.
So this time, I ran that script once, directly at my Resources directory, thus removing all Extended attributes from the resource files, like this
mini-mac7:Resources $ xattr -cr . || echo Clear mini-mac7:Resources $ ls -la@ total 392 drwxr-xr-x 5 mshneor staff 160 Jun 28 13:57 . drwxr-xr-x 12 mshneor staff 384 Jun 28 13:44 .. -rw-r--r-- 1 mshneor staff 19688 Jun 28 13:44 PfPtShield.png -rw-r--r-- 1 mshneor staff 172435 Mar 16 2017 Proofpoint-logo-reg-K.png -rw-r--r-- 1 mshneor staff 258 Jun 28 13:44 factoryDefaults.plist mini-mac7:Resources $
And sure enough - next build worked like a charm. I really hope git is smart enough to push the removal of extended attributes to the repo too.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: