334

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 ?

4
  • 2
    did you make clean and "alt" clean ?
    – thorb65
    Commented Sep 23, 2016 at 7:05
  • means? I just recreated certificates from xcode accounts and re generated profiles in website and re tried...still no luck. Commented Sep 23, 2016 at 12:53
  • 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. Commented Sep 28, 2016 at 9:52
  • plus for cocos2d-x
    – fnc12
    Commented Dec 5, 2016 at 10:49

27 Answers 27

730

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.

27
  • 7
    This fixed code sign error in Xcode 8. Great solution. Commented Sep 24, 2016 at 12:40
  • 4
    I have 110 files with that. What would be a bash command which would automatically treat all of them?
    – Fawkes
    Commented Sep 26, 2016 at 12:24
  • 1
    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. Commented Jan 13, 2017 at 18:12
  • 1
    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.
    – Jim Merkel
    Commented May 1, 2017 at 23:57
  • 3
    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! Commented Jun 21, 2019 at 23:46
190

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 {} \;
5
  • 12
    This should be the accepted answer. Simpler, faster, and requires no manual effort. I had 80 files with problems, according to @NatureFriend's answer.
    – Roger Oba
    Commented Sep 29, 2016 at 23:32
  • One quicker terminal-less solution for me was just to drag all images in ImageOptimizer (which trashes all useless attributes also). Commented Oct 4, 2016 at 15:48
  • I had saved a new icon from pixelmator and had the same issue. Thanks.
    – Guy Lowe
    Commented Feb 18, 2017 at 2:26
  • 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.
    – Randoramma
    Commented Jul 5, 2018 at 16:36
  • 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...
    – innom
    Commented Aug 22, 2022 at 9:17
112

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 .

5
  • 5
    I tried it in terminal and "insufficient space for argument"
    – Fawkes
    Commented Sep 26, 2016 at 12:27
  • 1
    This worked as a charm! Also had to do a Product > Clean in XCode, but then my project built! Commented Sep 28, 2016 at 9:50
  • 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. Commented Jan 30, 2017 at 15:18
  • I was building with Corona SDK and facing the same issue. xattr -rc Worked for me.
    – AbaEesa
    Commented Sep 27, 2017 at 16:55
  • find . | xargs -0 xattr -c worked for me`. After running that command, I cleaned the project, and rebuilt.
    – Fritz Lim
    Commented Mar 13, 2019 at 18:07
40

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

7
  • 1
    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.
    – clozach
    Commented Aug 24, 2017 at 17:49
  • 1
    THANK YOU! after 2 hours of searching for a solution this worked. Commented Mar 10, 2019 at 18:48
  • 1
    Finally! After hours of trying other solutions, this fixed it!! Try this first, but substitute the path shown by the codesign error
    – jmf1205
    Commented Jun 26, 2019 at 7:30
  • for me, the issue was an image in source code... so I added a run script which did this xattr -cr "$PROJECT_DIR" Commented Jan 10, 2020 at 23:34
  • 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
    – M4trix Dev
    Commented Jan 12, 2020 at 20:20
38

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

xattr -rc .
4
  • 1
    Yes, sometimes only clearing attrs inside Project directory helps.. Lame Apple, why to make such crappy things Commented Feb 21, 2018 at 23:43
  • In addition to the top voted answer this also worked as an alternative Commented Jun 12, 2019 at 4:13
  • I also had to clean the project folder <cmd+K> afterwards for this to work Commented Jun 12, 2019 at 4:57
  • 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.
    – Leo Braun
    Commented Feb 12, 2023 at 10:00
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

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.
    – JanR
    Commented Jan 24, 2018 at 16:58
  • I wasted 2 days on this and this solution finally worked for me!
    – bhakti123
    Commented Nov 16, 2018 at 8:38
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

8
  • It worked for me. Thanks a lot for your usefull app!
    – Blue
    Commented Nov 9, 2016 at 9:18
  • 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!
    – XIII
    Commented Nov 14, 2016 at 5:45
  • Downloaded your app and it cleaned everything up for me! Thank you!
    – Bobby
    Commented Dec 18, 2016 at 6:21
  • I will fix crash for large project as soon I will have some spare time!
    – ingconti
    Commented Nov 14, 2017 at 8:15
  • Yeah I'm running into the crash you mentioned. Either way, very cool that you created a free tool to help the community. +1 Commented Jan 1, 2018 at 17:42
16

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

6
  • 1
    I moved from iCloud Drive to the Desktop and works properly. Thanks
    – drasick
    Commented Oct 5, 2016 at 16:42
  • 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 Commented Oct 6, 2016 at 20:21
  • This was also the problem for me: iCloudDrive causes this really annoying error, I reported a bug to Apple -> 31740606 Commented Apr 20, 2017 at 20:15
  • 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.
    – daver
    Commented Jun 16, 2020 at 4:29
  • Thanks! This was the right solution for me. The folder I was working with was synced on OneDrive.
    – Oyzuu
    Commented Jan 18 at 16:19
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

2
  • Where are you adding this?
    – RGriffiths
    Commented Mar 29, 2017 at 22:00
  • Good solution. Save my time.Thank you.
    – Bruce
    Commented Apr 17, 2021 at 16:01
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.

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

2
  • 1
    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. Commented Mar 11, 2018 at 18:38
  • It worked, thanks! The solution for me was executing "xattr -rc ." in the derived data project folder instead in the project folder.
    – BIOS-K
    Commented Feb 29, 2020 at 1:56
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.

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

2

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.

5
  • this brick my project, don't use it guys Commented Aug 26, 2017 at 5:24
  • This bricked my scheme. and fixing that issue I remove .scodeproj file accidentally and then I created new project and transferred previous files Commented Aug 28, 2017 at 10:00
  • Then it happened due to your mistake. I tried abode code and don't have any problem. Commented Aug 28, 2017 at 10:03
  • Bro after using above command in my case created an issue for me. then to solve that I stuck into another issue. Commented Aug 28, 2017 at 10:05
  • @RajeshMaurya in Mac, draging folder to terminal copies full path of folder. No need to try get info and all :-
    – Guru
    Commented Apr 2, 2021 at 10:29
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.

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.
    – Anessence
    Commented Oct 16, 2017 at 4:15
1

Open terminal and just run this command.

xattr -cr "path to .app file"

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

1

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

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.

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)

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.

0

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

0

You can remove the derived data Xcode -> Preferences

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

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.

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

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.