ChatGPT解决这个技术问题 Extra ChatGPT

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

Already tried : Code Sign Error on macOS Sierra, Xcode 8

https://i.stack.imgur.com/wbcW4.png

CodeSign /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super\ Flow\ Flip.app
    cd "/Volumes/Development/Project/Top Best Games/19. Lets Flow/35/let's FLOW - source/proj.ios_mac"
    export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

Signing Identity:     "iPhone Distribution: New Free Games (2CHN583K4J)"
Provisioning Profile: "Super Flow Flipp AppStore"
                      (c6c30d2a-1025-4a23-8d12-1863ff684a05)

    /usr/bin/codesign --force --sign E48B98966150110E55EAA9B149F731901A41B37F --entitlements /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Intermediates/Flow.build/Debug-iphoneos/Super\ Flow\ Flip.build/Super\ Flow\ Flip.app.xcent --timestamp=none /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super\ Flow\ Flip.app

/Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super Flow Flip.app: resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1

https://i.stack.imgur.com/DdEtl.png

https://i.stack.imgur.com/bI1wk.png

How to fix this problem ?

did you make clean and "alt" clean ?
means? I just recreated certificates from xcode accounts and re generated profiles in website and re tried...still no luck.
Arnold Roas answer below did the trick for my project. But you also might have to do a Product > Clean in XCode for the compile to succeed afterwards.
plus for cocos2d-x

C
Community

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.


This fixed code sign error in Xcode 8. Great solution.
I have 110 files with that. What would be a bash command which would automatically treat all of them?
Thanks,Worked for me!!
This is a lifesaver. I spent hours on this.
Thank you so much for sharing, saved me hours if not days!
M
Mark McCorkle

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 {} \;

This should be the accepted answer. Simpler, faster, and requires no manual effort. I had 80 files with problems, according to @NatureFriend's answer.
Thank you! The hours I spent trying to find the answer to this strange error - what a colossal waste of time!
One quicker terminal-less solution for me was just to drag all images in ImageOptimizer (which trashes all useless attributes also).
I had saved a new icon from pixelmator and had the same issue. Thanks.
This worked for me.. I was getting permission denied on the above 'xcattr -cr' command (even directed to do via Apples documentation listed above: developer.apple.com/library/archive/qa/qa1940/_index.html Running Xcode 9.3 on High Sierra 10.13.4.
A
Arnold Roa

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 .


I tried it in terminal and "insufficient space for argument"
This worked as a charm! Also had to do a Product > Clean in XCode, but then my project built!
Thank you man, it works. In my case the problem was I can test in device without issue but when I try in simulator it doesn't work and shows the above problem. Your solution fixed my problem.
xattr -rc . Work!
I was building with Corona SDK and facing the same issue. xattr -rc Worked for me.
A
A.Badger

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:

Select your target in XCode Select the Build Phases tab Press the + symbol Select New Run Script Phase 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.

https://i.stack.imgur.com/hgkrP.png


The problem only appears for me in a project created from an otherwise-identical project using ⌘-D in the Finder. For some reason, none of the more popular solutions worked for me. This one did.
THANK YOU! after 2 hours of searching for a solution this worked.
Finally! After hours of trying other solutions, this fixed it!! Try this first, but substitute the path shown by the codesign error
for me, the issue was an image in source code... so I added a run script which did this xattr -cr "$PROJECT_DIR"
many thanks, this still works. In my case I added xattr -cr ~/Users/msc/OneDrive/01 Work/APP/Flutter/lts-flutter/build/ios/Debug-iphoneos || echo Clear
R
Ram G.

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

xattr -rc .

Yes, sometimes only clearing attrs inside Project directory helps.. Lame Apple, why to make such crappy things
In addition to the top voted answer this also worked as an alternative
I also had to clean the project folder afterwards for this to work
c
comrade

There is official Apple answer for this issue in Technical Q&A QA1940.

This is a security hardening change that was introduced with iOS 10, macOS Sierra, watchOS 3, and tvOS 10. Code signing no longer allows any file in an app bundle to have an extended attribute containing a resource fork or Finder info. To see which files are causing this error, run this command in Terminal: xattr -lr You can also remove all extended attributes from your app bundle with the xattr command: xattr -cr

<path_to_app_bundle> can be replaced with directory of your Xcode project. For example ~/Development/MyProject


After working through almost all other proposed solutions the xattr -lr <path_to_app_bundle> finally lead to the right files. Got a Localizable.strings from the agency with Finder-Tags and those caused the Codesign to fail.
I wasted 2 days on this and this solution finally worked for me!
i
ingconti

All about clearing files is fine, but tedious for multiple projects.

graphics apps, (like photoshop in old versions) write additional info (we now call it metadata..) in an old fashion in external files, or they came frm older OSX, files like:

"com.apple.ResourceFork" and "com.apple.FinderInfo", when unzipping folder, for example.

Xcode 8 refuses to add it to a build (as You added them to a project with a "git --add ." maybe..) You can find in terminal recursively and delete them, but can be tedious.

I wrote a small free utility to delete it.. hope it can help..

https://itunes.apple.com/us/app/cleandetritus/id1161108431?ls=1&mt=12


It worked for me. Thanks a lot for your usefull app!
This one was the only solution that worked with me, although the app has crashed many times "probably due to the large number of the project files" but it has cleaned the files and the project was finally working. Thanks!
Downloaded your app and it cleaned everything up for me! Thank you!
Have a +1. Thank you
I will fix crash for large project as soon I will have some spare time!
B
Bobjt

For those (like me) who are just trying to develop an app without having to strip extended attributes on every new photoshop created PNG added to the macOS target, you can temporarily disable code signing by adding a user defined build setting:

CODE_SIGNING_ALLOWED = No 

Obviously, one distributing an app needs to eventually deal with the issue but this enables development in cases like mine where it wasn't necessarily straightforward to omit code signing in Sierra (on past OS X / Xcode it was easier to do so).

Per RGriffith's comment, here are a few screenshots for those who aren't sure how the custom build setting is added.

https://i.stack.imgur.com/YcjcW.png

https://i.stack.imgur.com/bSiIe.png


Where are you adding this?
Good solution. Save my time.Thank you.
A
Abdul Nasir B A

Simple solution:-

How I did [Working for me]

Step 1:- Go to this folder - from your finder press option Go - > Go to Folder

then type your project path like this example:- Library/Developer/Xcode/DerivedData/yourprojectname/Build/Products/Debug-iphoneos

Now you can see a window pop with list of available File, There you see yourApp.app file [ Don't do anything just wait for step 2].

Step 2:- Open new Terminal and type just cd then just drag step 1 yourApp.app to terminal, now you will get the path for the app, now press enter button.

Step 3:- Now type this command **

xattr -rc .

Don't miss "."(Dot) press enter button.

That's it, Go to your Xcode project and clean and run again.


F
Fawkes

-----In case you can't apply the solutions above, because of lack of bash knowledge or something else.

I had this problem as soon as I enabled iCloud Drive on my Sierra. And my project was in a folder which was synced with iCloud Drive. I suppose this is what adds those additional attributes.

Temporary solution:

Disable iCloud Drive for the folder where your project is.


I moved from iCloud Drive to the Desktop and works properly. Thanks
This was part of the solution for me. I had a project on my desktop which was being backed up to iCloud under Sierra. I still needed to type xattr -rc . in the terminal to delete the offending files after moving the project off of the desktop. None of the other solutions worked for this step
This was also the problem for me: iCloudDrive causes this really annoying error, I reported a bug to Apple -> 31740606
This was essentially my problem as well, but I didn't have to disable iCloud for my project folder, or move the project folder, or anything like that. I just went into Xcode Prefs->Locations->Advanced and selected the "Unique" option for Build Location. I had been using a build location in subfolder of the xcode project file, which was on the iCloud drive. I think the default is Unique, and I don't know why I ever changed it, maybe to make it easier to find the executable after a build.
v
velhala

You will need to delete the app bundle folder and rebuild the app as explained below.

My app is called: augment

In terminal window, goto your app folder e.g.: cd /Users/username/Library/Developer/Xcode/DerivedData/

In terminal window run command for your app folder e.g.: xattr -cr augment-flmbiciuyuwaomgdvhulunibwrms

Clean>Build>Run.

There is also a free app on Mac Appstore called "CleanDetritus" which will do removal of these.


I'm using Flutter to generate the iOS app and Clean>Build>Run from Xcode solved the "resource fork, Finder information, or similar detritus not allowed" error on flutter console.
It worked, thanks! The solution for me was executing "xattr -rc ." in the derived data project folder instead in the project folder.
M
ManuQiao

This problem came to me yesterday.

(What's wrong) I updated image resources by manually replacing file in finder and I failed with this compilation error.

(What's right) Don't update image in this way. After that I dragged images to 'xcassets' in Xcode. No more error appear again.


A
Andrey

My problem is every change I make in the code and execute again the error reappears. Then I find a solution to execute the command automatically every compilation/execution of code.

Thanks to @rich-able I discovered "Run Script". Then I put the command "xattr -cr ." in the field.

https://i.stack.imgur.com/tqigS.png


Y
Yogesh Dalavi

The problem is in the derived data, You should clean the derived data and then clean the project and build. Please check this link.


R
Rajesh Maurya

One of the best solution is Go to terminal type this

xattr -cr "Full path of your project"

To find full path of your right click on Xcode project->get info -> copy path and replace with . Then type below command

xattr -cr "Full path of your project"

Clean and build done.


this brick my project, don't use it guys
This bricked my scheme. and fixing that issue I remove .scodeproj file accidentally and then I created new project and transferred previous files
Then it happened due to your mistake. I tried abode code and don't have any problem.
Bro after using above command in my case created an issue for me. then to solve that I stuck into another issue.
@RajeshMaurya in Mac, draging folder to terminal copies full path of folder. No need to try get info and all :-
e
emp

The simplest fix may be if you are using git. Try:

$ git stash
$ git stash pop

Git does not store file metadata, the above will strip it all away.


I had this issue under Xcode 9. Solution above fixed the issue. You should have project under git source control and haven't committed any file yet.
I
Idrees Ashraf

Open terminal and just run this command.

xattr -cr "path to .app file"


J
JerryZhou

I found that if I add color tag on the folder under DerivedData, it will give the above error when debug on device.

Remove the color Tag fix this error for me.

https://i.stack.imgur.com/NiqB9.png


F
Frederik Witte

My problem was that I used cordova to build the app around 1 year ago, but it wasn't compatible with the new version of xcode, so I simply used cordova build ios and it worked again.


J
Joe Aspara

If the xattr commands doesn't the trick this may be due to an XCode 9 bug: let's try to remove and re-add the resource folder (it was a .xcassets in my case) containing the affected files from Xcode. (you should understand which are the affected files previous through the xattr -lr command)


I
Irfan

I'm also facing the same issue, got fixed by just restarting my Macbook.


M
Mickael Belhassen

You can remove the derived data Xcode -> Preferences

And click on the arrow below Derived Data, and empty the folder Derived Data


A
Ankur Lahiry

I don't know what happened to me, but when I was running flutter app on simulator, I was encountered by the error. I used flutter clean command and removed the derived data and then everything goes fine.


B
Ben Butzer

My .app was on a network mounted drive.

codesign -f -vv --preserve-metadata=entitlements -s {*my Apple distribution cert SHA*} my.app
my.app: resource fork, Finder information, or similar detritus not allowed

I don't know if too long path or the fact it was on a NAS device was a problem. I copied the .app to my local Downloads directory, and then was able to codesign.

my.app: signed app bundle with Mach-O thin (arm64) [*com.something.my*]

A
ACLima

This happened to me as well when I duplicated a .plist file and edited it, instead of creating a new one. the xattr -lr <path> command helped me identify the problematic file.


A
Abhijith

My issue was related to unintended changes on framework integrated using Carthage. I had modified one line in framework by mistake and it didn't show up in git because dependency build folder was ignored from git.

Solution : Deleted framework folder in Carthage and rebuilt it.