Hi all, reposting this from here: https://unix.stackexchange.com/questions/789849/xattr-c-not-removing-com-apple-finderinfo-attribute
I came to this problem because my Xcode project was failing to build due to the error "resource fork, Finder information, or similar detritus not allowed" (was trying the solutions on this post).
Basically, running xattr -cr .
in the terminal on my project directory removes all extended attributes except com.apple.FinderInfo, which stays on all .xcodeproj and .xcworkspace files. I've tried everything under the sun, from sudo
to xattr -d
to dot_clean
to tar
to rsync
and nothing works. Is this just an immortal attribute that can never be removed? I'm truly at a loss here, this is for my senior thesis project.
Not really. The Finder info is a 32-byte binary data structure. For files, the first field is the traditional Mac OS type type, where 'TEXT'
is the type used for text files. The exactly structures are defined in Finder.h
, part of the Core Services framework in the macOS SDK.
In your hex dump all the bytes are zero except for the one at offset 0x08. That’s the first byte of the finderFlags
field. The value, 0x2000, corresponds to the bundle flag (kHasBundle
). you can set or clear this using SetFile
:
% xattr MyTrue.app
% SetFile -a B MyTrue.app
% xattr MyTrue.app
com.apple.FinderInfo
% xattr -px com.apple.FinderInfo MyTrue.app
00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
% SetFile -a b MyTrue.app
% xattr MyTrue.app
Which brings me back to my original point. This is not being set by accident. Something in your build process is deliberately setting this flag. You need to track down who that is and get them to stop.
If you really want the bundle bit set on your plug-in, set it after signing the code. Doing this at the top level doesn’t break the seal on the code signature. For example:
% xattr MyTrue.app
% codesign -v -vvv MyTrue.app
MyTrue.app: valid on disk
MyTrue.app: satisfies its Designated Requirement
% SetFile -a B MyTrue.app
% xattr MyTrue.app
com.apple.FinderInfo
% codesign -v -vvv MyTrue.app
MyTrue.app: valid on disk
MyTrue.app: satisfies its Designated Requirement
Note One of thes Finder flags is kHasCustomIcon
, set when you use the Finder to apply a custom icon to a folder. It would be Bad™ if doing that broke the seal on the code signature.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"