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

27

328

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

Please see image showing error enter image description here

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

In Code Sign section its allowing me to select profile and certificate...but still giving error. enter image description here

enter image description here

How to fix this problem ?

Aleras answered 23/9, 2016 at 4:54 Comment(4)
did you make clean and "alt" clean ?Hath
means? I just recreated certificates from xcode accounts and re generated profiles in website and re tried...still no luck.Aleras
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.Soche
plus for cocos2d-xAntipodal
U
715

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.

Solution 2:

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

xattr -cr .

Clean Xcode and Re-build.

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.

Ungracious answered 23/9, 2016 at 18:46 Comment(27)
This fixed code sign error in Xcode 8. Great solution.Aleras
I have 110 files with that. What would be a bash command which would automatically treat all of them?Iceskate
I simply used find . -type f -name '.' -exec xattr -c {} \; for tons of files even including the .xib files. one of my .aif file was killed... please correct me if I was wrong.Marlanamarlane
@JiulongZhao, sorry not getting what's wrong with your execution. Please post your problem in separate question...some experts may help.Ungracious
@TDM, open terminal and goto project root directory and execute. app.box.com/s/usdq26vib991jx0tk6fulggg6p3p7ic3Ungracious
Thanks. I actually ended up figuring it out, but that didn't seem to fix it. Will try Solution 2Bluebird
@NagarajS Did you try both solution 1 & 2 ?Ungracious
How can that also happen for nib files?! -rw-r--r--@ 1 Apple staff 6905 Jun 26 2015 LibraryVideoViewController.xib com.apple.FinderInfo note that xcode didn't show the error for the nib fileForestaysail
I was building for iPhone 7 Plus simulator without issue, but then I switched to build on a real device for testing and when I switched back to the simulator, I got this error. Solution 1 worked for me, thanks a bundle.Glockenspiel
I've been using Xcode for 6 years during my off time. I code professionally at work with Visual Studio and Eclipse for 6 years. Comparatively, I can't say enough how terrible Xcode is to utilize.Solingen
By the way, the xattr -rc fix won't work with tif images. You have to remove tif images from the project. I guess tif images come under the heading of "detritus" according to Apple.Gombach
Great answer except the fact I had to do the same thing with "*.json" files - in one of them there was my problem hidden.Marsha
Why did you remove credit to my answer? ;-) @Iceskate You can try file specific bash command like Mark McCorkle answered.Sforza
@MarkMcCorkle Solution 1: Inspired by Mark McCorkle's Answer..Updated Now..CheersUngracious
@MarkMcCorkle I just stated the reason of this problem appearing in the first place and as mentioned in my answer if you're out of luck with understanding how bash works, you can do the dumb way and at least be sure you'll not encounter that again or apply a code which is not your own in your terminal. Since my answer was written ages ago, you can be sure I managed to solve it (;Iceskate
The statement was for Guru. It was just a quote with your name in it @Fawks. No worries, problem solved. ;-)Sforza
First solution worked like a charm in XCODE 9...thank you!Mourn
Worked for Xamarin iOS app as well. Very nice +1Skewbald
#48379104 please check, thank you!Kristine
Solution 1 fixed this issue with Flutter 1.0.0.0 'myapp' sample built and run from VSCode.Astereognosis
You can also get this problem with your font files, in my case was simply fixed with: find . -type f -name '*.ttf' -exec xattr -c {} \;Rixdollar
I'm using ARKit, I imported a 3d image .dae file and it's .jog texture from from blender.org and got this error. What fixed it for me was the 2nd option but I had to to cd to the art.scnassets folder to get to the image causing the problemMosher
Perfect, very good explanation. BTW, the first command is a bit confusing, instead of xattr -cr <path_to_app_bundle> it should probably read xattr -cr <path_to_project_dir>, or just xattr -cr . Works like a charm!Stereobate
If you get the error "option -c not recognized" when running the xattr command, it's probably because you have the GNU coreutils version in your path ahead of the stock macOS version. You can choose the correct xattr by instead running: /usr/bin/xattr -cr <path>.Grimalkin
@Stereobate thanks! working for me. Just go to project root directory and run this command xattr -cr .Hollyanne
I used solution 4 and it worked, but right after changing something in the code(commenting an import) giving me again this problem. Now if I uncomment it, it still giving me the same error. so might have to run solution 4 again. Is there any permanent solution to this?Avocation
Addition: Please don't forget to check your local packages that are using assets. You might not find com.apple.FinderInfo within your project but from the local package folders.Overmodest
S
188

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 {} \;
Sforza answered 26/9, 2016 at 14:52 Comment(5)
This should be the accepted answer. Simpler, faster, and requires no manual effort. I had 80 files with problems, according to @NatureFriend's answer.Milissamilissent
One quicker terminal-less solution for me was just to drag all images in ImageOptimizer (which trashes all useless attributes also).Carpetbag
I had saved a new icon from pixelmator and had the same issue. Thanks.Tewfik
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.Elysian
I searched far and wide, for days. And this was the issue. I could deploy to a smartphone, but not build my application. All I did was change one picture in the resources. I worked with Xamarin.forms and Visual Studio, and the error VS generated seemed to be totally unrelated. Sometimes "native linking failed", then just some random libary not beeing compatible, but in the end., those errors were all bullsh.... it was the image containing meta data...Pilliwinks
H
111

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 .

Hessian answered 25/9, 2016 at 18:38 Comment(5)
I tried it in terminal and "insufficient space for argument"Iceskate
This worked as a charm! Also had to do a Product > Clean in XCode, but then my project built!Soche
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.Dunstable
I was building with Corona SDK and facing the same issue. xattr -rc Worked for me.Treadwell
find . | xargs -0 xattr -c worked for me`. After running that command, I cleaned the project, and rebuilt.Crowder
W
39

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

Wit answered 29/3, 2017 at 13:27 Comment(7)
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.Maser
THANK YOU! after 2 hours of searching for a solution this worked.Drumhead
Finally! After hours of trying other solutions, this fixed it!! Try this first, but substitute the path shown by the codesign errorMiscarriage
for me, the issue was an image in source code... so I added a run script which did this xattr -cr "$PROJECT_DIR"Whooper
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 ClearPad
xattr -lc, suggested in another answer, confirmed that the attributes in question were indeed from DropBox since my project folder is inside my DropBox folder. This suggestion to strip those attributes in the DerivedData folder worked perfectly and left my DropBox folder intact!Jeaniejeanine
This works for me. I'm using flutter, ios build. With the Mac OS Big Sur, Xcode Beta 11Stellite
B
36

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

xattr -rc .
Ballenger answered 23/10, 2017 at 21:2 Comment(4)
Yes, sometimes only clearing attrs inside Project directory helps.. Lame Apple, why to make such crappy thingsIseult
In addition to the top voted answer this also worked as an alternativeMosher
I also had to clean the project folder <cmd+K> afterwards for this to workMosher
just note that this command will also remove the folder's custom icon AND kill aliases in the folder (they'll stop working). so if you do have any aliases, back them up first, then restore after running the command. you'll also have to restore the custom icon.Lysozyme
S
24

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 <path_to_app_bundle>

You can also remove all extended attributes from your app bundle with the xattr command: xattr -cr <path_to_app_bundle>

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

Syndic answered 27/11, 2016 at 9:24 Comment(2)
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.Scrouge
I wasted 2 days on this and this solution finally worked for me!Rowan
C
17

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

Colloidal answered 15/10, 2016 at 6:27 Comment(9)
It worked for me. Thanks a lot for your usefull app!Datura
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!Heavyarmed
Downloaded your app and it cleaned everything up for me! Thank you!Antonyantonym
Have a +1. Thank youGoosefish
I will fix crash for large project as soon I will have some spare time!Colloidal
Yeah I'm running into the crash you mentioned. Either way, very cool that you created a free tool to help the community. +1Skewbald
update: even though it was crashing it got me past this issue for my Xamarin.iOS app. Thanks!Skewbald
Like someone said in the customer reviews... I owe you dinner! lol. Wonderful app!Minded
Thank you; a CS4 cure.Louisiana
I
14

-----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.

Iceskate answered 26/9, 2016 at 13:14 Comment(6)
I moved from iCloud Drive to the Desktop and works properly. ThanksWilfordwilfred
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 stepLerma
This was also the problem for me: iCloudDrive causes this really annoying error, I reported a bug to Apple -> 31740606Experienced
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.Francois
Thanks! This was the right solution for me. The folder I was working with was synced on OneDrive.Beastings
It's March 1st, 2024, and this comment is still the one that was most helpful for me. I even reached out to Apple Support, and they gave me the details from the accepted answer on this question. If you find yourself trying to xattr -cr . a bunch and it appears to have no effect, then this is the correct answer. iCloud sync automatically re-adds those attributes just as fast as you remove them.Underwent
B
13

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.

enter image description here

enter image description here

Branchia answered 18/1, 2017 at 18:41 Comment(2)
Where are you adding this?Waterish
Good solution. Save my time.Thank you.Charette
P
11

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.

Prebo answered 13/10, 2016 at 10:2 Comment(0)
M
4

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.

Muscadel answered 6/2, 2018 at 22:57 Comment(2)
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.Detection
It worked, thanks! The solution for me was executing "xattr -rc ." in the derived data project folder instead in the project folder.Shrunk
T
2

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.

Thun answered 7/3, 2017 at 1:39 Comment(0)
B
2

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.

XCODE Solution

Bump answered 8/6, 2017 at 5:34 Comment(0)
A
1

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.

Alfreda answered 14/7, 2017 at 5:29 Comment(5)
this brick my project, don't use it guysAmphibology
This bricked my scheme. and fixing that issue I remove .scodeproj file accidentally and then I created new project and transferred previous filesAmphibology
Then it happened due to your mistake. I tried abode code and don't have any problem.Alfreda
Bro after using above command in my case created an issue for me. then to solve that I stuck into another issue.Amphibology
@RajeshMaurya in Mac, draging folder to terminal copies full path of folder. No need to try get info and all :-Ungracious
L
1

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.

Lejeune answered 6/10, 2017 at 21:58 Comment(1)
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.Selwyn
C
1

Open terminal and just run this command.

xattr -cr "path to .app file"

Cathepsin answered 6/12, 2017 at 7:35 Comment(0)
E
1

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.

enter image description here

Erubescence answered 13/6, 2018 at 8:7 Comment(0)
A
0

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.

Acapulco answered 24/3, 2017 at 9:44 Comment(0)
S
0

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)

Stace answered 18/10, 2017 at 15:25 Comment(0)
M
0

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

Moussorgsky answered 5/12, 2017 at 12:26 Comment(0)
A
0

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

Anticlerical answered 4/1, 2018 at 12:39 Comment(0)
U
0

You can remove the derived data Xcode -> Preferences

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

Undercoating answered 18/9, 2019 at 11:27 Comment(0)
T
0

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.

Tilth answered 10/6, 2020 at 14:43 Comment(0)
M
0

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*]
Milinda answered 14/6, 2021 at 21:34 Comment(0)
J
0

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.

Joby answered 22/11, 2021 at 11:31 Comment(0)
G
0

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.

Gibby answered 23/5, 2022 at 13:4 Comment(0)
L
0

Sonoma 14.2.1, M2 Pro - same problem with running applications

Most of the answers didn't help, only this:

Navigate to /Applications directory and execute sudo xattr -rc .

Hope I saved your time ... :)

Lapse answered 3/1 at 6:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.