ios - Code Sign Error in macOS Monterey, Xcode - resource fork, Finder information, or similar detritus not allowed

ID : 10193

viewed : 27

Tags : iosxcodexcode8macos-sierrafile-forksios

Top 5 Answer for ios - Code Sign Error in macOS Monterey, Xcode - resource fork, Finder information, or similar detritus not allowed

vote vote

94

Solution 1:

Apple Developer Website Answers above problem Here.

Execute below command in terminal : First goto projects root folder

 xattr -cr <path_to_project_dir> 

Clean Xcode and Re Build. Cheers

Solution 2:

Just go to project root directory and run this command xattr -cr .

xattr -cr . 

Clean Xcode and Re Build. Done.

Solution 3:

You can fix this problem by finding files which holds finder information.

In terminal, goto project root directory and execute

ls -alR@ . > kundapura.txt 

This creates kundapura.txt in current directory. Now search for com.apple.FinderInfo and clear this attributes for all files. You can do it like this

xattr -c <filename> 

Example: xattr -c guru.png

Once you clear all then code sign works. Clean Xcode and Re Build. Cheers

Solution 4: Inspired by Mark McCorkle's Answer

In terminal, goto project's root directory and execute one by one command

  find . -type f -name '*.jpeg' -exec xattr -c {} \;   find . -type f -name '*.jpg' -exec xattr -c {} \;   find . -type f -name '*.png' -exec xattr -c {} \;   find . -type f -name '*.json' -exec xattr -c {} \; 

Clean Xcode and Re Build. Done.

vote vote

88

The error is from attributes inside your image files. This happened from our graphics designer saving images from photoshop with attributes.

Here is a simple command to find all of your png files and remove their attributes. Run this in your projects root directory from terminal. Clean and rebuild; problem solved.

find . -type f -name '*.png' -exec xattr -c {} \; 
vote vote

79

If you have this error when codesigning an app:

resource fork, Finder information, or similar detritus not allowed Command /usr/bin/codesign failed with exit code 1

Go to your project root folder and execute

find . | xargs -0 xattr -c 

This will clear attributes for all files.

In Sierra, the rules on what can be in a signed bundle have been tightened, and resource forks are no longer allowed. AppleScript has been saving information in resource forks forever, although that information has been unused for a long time. With Sierra, when you save a script, this resource fork information will no longer be saved.

It means you cannot codesign a script that was last saved in a version before Sierra; you have to save in Sierra to be able to sign in Sierra.

The people likely to be affected by are who bundle other scripts within their scripts (cordova?). They will not be able to sign the container script until all the embedded scripts have been resaved under Sierra.

UPDATE:

Seems like this also works:

xattr -rc . 

If you have any insufficient permissions error try to prepend sudo: sudo xattr -rc .

vote vote

64

The easiest way to handle attributes on your source files is to have Xcode clear up the archive before it runs codesign. To do this:

  1. Select your target in XCode
  2. Select the Build Phases tab
  3. Press the + symbol
  4. Select New Run Script Phase
  5. Enter the following for the script:

    xattr -cr ~/Library/Developer/Xcode/DerivedData || echo Clear

Now when you build your target it will clear out any attributes that would have broken codesign. By clearing out at this stage you don't have to alter your source code / project directory.

The "|| echo Clear" part of the script ensures that the project build continues even if xattr errors.

This method is good if you use programs such as DropBox on your code repository that add the attributes, as it doesn't change your source project, only the built archive.

You may need to change the path to match your DerivedData directory - this path will be shown next to the codesign error.

xattr codesign xcode fix

vote vote

52

I have used following command. Use terminal window. Navigate to your Project and execute following:

xattr -rc . 

Top 3 video Explaining ios - Code Sign Error in macOS Monterey, Xcode - resource fork, Finder information, or similar detritus not allowed

Related QUESTION?