164

Every time I build a console is showing this message.

CodeSign /Users/admin/Desktop/AppStoreBuild/Project201/build/Debug-iphonesimulator/Project.app (in target: Desker) cd /Users/admin/Desktop/AppStoreBuild/Project201 export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate

Signing Identity: "-"

/usr/bin/codesign --force --sign - --entitlements /Users/admin/Desktop/AppStoreBuild/Project201/build/Project.build/Debug-iphonesimulator/Project.build/Project.app.xcent --timestamp=none /Users/admin/Desktop/AppStoreBuild/Project201/build/Debug-iphonesimulator/Project.app

/Users/admin/Desktop/AppStoreBuild/Project201/build/Debug-iphonesimulator/Project.app: resource fork, Finder information, or similar detritus not allowed Command CodeSign failed with a nonzero exit code

... Is there any way to identify the cause of this failure? It's showing Signing Identity: "-" when I try to run in the simulator also. why do we need signing identity in simulator? And one more thing is if I quit Xcode and restart, it will build properly when I change code or add a method will again build failing.

Willie Cheng
  • 7,679
  • 13
  • 55
  • 68
Test Test
  • 1,761
  • 3
  • 10
  • 12

47 Answers47

382

I had that problem and Xcode failed to compile on the device, but on simulator, it worked fine.

I solved with these steps:

  1. Open keychain access.
  2. Lock the 'login' keychain.
  3. Unlock it, enter your PC account password.
  4. Clean Project in the product menu.
  5. Build it Again.

And after that everything works fine.

Community
  • 1
  • 1
omanosoft
  • 4,239
  • 1
  • 9
  • 16
  • 21
    in my case it was unlocked...so I just locked it and then cleaned and built and Xcode asked me to enter my password. Working – Jad Nov 09 '18 at 16:37
  • 1
    This is perfect solution for me in my case i have donwloaded xcode10.1 separately and i had xcode 10.0 previous . After that it was giving the above after doing the solution provided by @omanosoft it worked – Abhijit Chakra Jan 07 '19 at 16:26
  • Would add that for me it worked without point 4. To avoid lenghty cleans and builds. – Yassine S. Apr 11 '19 at 18:08
  • 2
    It takes me half a day until I found your solution that saved me, thank you dear friend. – Bachir Mehemmel Apr 29 '19 at 13:48
  • this moved me to the next issue -- the entitlements for my new app that was re-using the AppId. Recommend creating a AppId for prototypes, etc. – mobibob Jun 28 '19 at 19:05
  • 2
    In my case the dialog pop-ups multiple times to enter the password. I entered my PC account password every time and after 7-10 times the access was accepted. – Adrian Buciuman Jul 11 '19 at 08:56
  • Works. Seems I have ever rejected a password request. – Dot Cink Sep 06 '19 at 06:14
  • Fixed the issue for me after I updated the provisioning profiles. When creating a fastlane build I would see the above codesign error. Would never have guessed that this was a keychain lock issue. It would be useful if Apple could fix this. –  Sep 17 '19 at 13:41
  • Worked for me, how i ended up with this error was that I Deny the password when xcode asked me, then never asked again. – Cristi Băluță Oct 02 '19 at 10:09
  • Outrageous that this obscure meandering path needs to be taken to fix this issue. How you found this fix is inconceivable. Must have taken many years. Thanks Apple. – Logicsaurus Rex Oct 14 '19 at 15:42
  • This worked for me. The problem occurred after I changed my computer's password, but I didn't connect the problem until I read this solution. Thanks! – iOS_Mouse Dec 16 '19 at 17:19
  • This worked for me but only the first time I got this error.. – stackato Dec 19 '19 at 15:46
  • 2
    @LogicsaurusRex Agreed. I cannot understand why building apps, let alone unit tests, should be tied to my user account. That's terrible developer experience. Such things need to be decoupled. AFAIK, not even Microsoft does that, and that's because they have tried to tie user accounts to certain developer tools like Visual Studio – OzzyTheGiant Dec 28 '19 at 01:27
  • This didn't work for me at first. But at some point I logged out of my Mac (NOT by restarting it) and then logged back in. That fixed it for me. Coincidence? Maybe. But if you are as desperate as I was, give it a try. – Mike Taverne Jun 04 '20 at 23:49
  • 1
    It didn't work for me. Apple really did a bad job. This always happen. The only solution for me is to recreate the certificate and provisioning profile. – Bagusflyer Jun 10 '20 at 04:43
  • 1
    I removed the Resources '?' folder and it worked .. – Junior Vieira Oct 03 '20 at 14:44
  • This worked for me: My distribution certificate was changes to untrusted in keychain, in Get Info -> Trust -> selected Always Trust (enter password)then again changed to Use System Default. After this distribution certificate marked as valid and then clean the build. – anas.p Mar 02 '23 at 11:53
89

None of the listed solutions worked for me. In another thread it was pointed out that including a folder named "resources" in the project causes this error. After renaming my "resources" folder, the error went away.

Paul Slocum
  • 1,454
  • 13
  • 18
  • 9
    This worked for me too. I had dragged a "Resources" folder from Finder into my project and used the default "Create folder reference" which created a blue "Resources" folder. I deleted that, dragged the same "Resources" folder from Finder into my project again, but this time I selected "Create groups" and now my project compiles without the signing error. – Mark Petereit Jul 06 '19 at 14:50
  • I encountered the same problem after adding the Firebase modules as per their instructions. I renamed the folder Resources to FirebaseResources and it worked nicely. Thank you. – ruralcoder Oct 14 '19 at 22:59
  • Nice, had the same issue when copying another code base. Odd, the other code base didn't have any issues, but when copied over it caused a new project to be impacted. Renaming the Resources folder did the trick. – matthew Feb 02 '20 at 19:07
  • can someone please tell me where and how I can find this resource folder – pratteek shaurya May 21 '20 at 17:21
  • @pratteekshaurya It would be a folder that you created within your project – Paul Slocum May 21 '20 at 22:15
  • 1
    Very nice. I'm using Swift Package Manager and had a folder named `Resources` and renaming that folder works. This is a serious OMG, WTF! – Chris Prince Dec 18 '20 at 03:28
  • wow this worked for me. tho i had a recent project with the folder Resources that worked just fine. maybe cos i copied the folder and not create it .. – SoliQuiD Jan 24 '23 at 09:20
53

For some people this happens after adding a .png file to an existing .scn assets folder, plus also a .wav file.

Xcode, owing to increased security, doesn't like extensions on files. You can fix these one at a time by cd'ing into the directory where the file is and removing their extended file attributes using the 'xattr' command in Terminal.

To Remove All Extended Attributes On a Single File

Use xattr with the -c flag to "clear" the attributes:

xattr -c yourfile.txt

To Remove All Extended Attributes On Many Files

To recursively remove extended attributes on all files in a directory, combine the -c "clear" flag with the -r recursive flag:

xattr -rc /path/to/directory

Fore more detail, see How do I remove the "extended attributes" on a file in Mac OS X?

This solution will also help when getting the code signing error: "resource fork, Finder information, or similar detritus not allowed."

Apple documentation: https://developer.apple.com/library/archive/qa/qa1940/_index.html

snibbe
  • 2,715
  • 1
  • 27
  • 34
xuzepei
  • 1,119
  • 11
  • 9
21

Fix

Remove extended file attributes in your resource files for good, not in the compiled application bundle:

  1. Open Terminal

  2. Change directory to the root of your source files

    $ cd /Users/rjobidon/Documents/My\ Project

  3. List all extended attributes

$ xattr -lr .
  1. Remove all extended attributes
$ xattr -cr .

Xcode errors

  • "Command CodeSign failed with a nonzero exit code"
  • "Resource fork, Finder information, or similar detritus not allowed"

Cause

Apple introduced a security hardening change, thus code signing no longer allows any file in an app bundle to have an extended attribute containing a resource fork or Finder info.

Sources

rjobidon
  • 3,055
  • 3
  • 30
  • 36
19

This happened to me just today, only after I added a .png image with 'hide extension' ticked in the get info. (Right click image) Ths image was added to the file directory of my Xcode project.

When unticked box and re-adding the the .png image to directory of Xcode, I then Cleaned and Built and worked fine after that, a very strange bug if you ask me.

Jonas
  • 474
  • 3
  • 17
  • 1
    Had this same issue with a .jpg, that didn't have it extension. Fixed after adding that. – eivindml Dec 07 '18 at 19:20
  • 1
    Thanks for saving me time. Kudos for relating that error to an image with a hidden extension. – Marcy Feb 20 '20 at 23:10
  • 1
    I experienced this issue with a png, but it had the extension visible. The image was exported from photoshop using "export layer comps to files". Deleting the image and re-exporting using "export as" fixed the issue. – Hermes Apr 12 '20 at 03:10
  • same problem here with PNG image! – Mr T May 18 '20 at 13:18
  • This worked for me - thank you - I can confirm this bug has not been fixed on Xcode 11.5 (11E608c) – Apneist Oct 19 '20 at 19:37
  • This happened to me also when I convert .dae to sceankit .scn . it automatically marked (hide extension) – MAMN84 Jun 19 '21 at 16:06
17

Try cleaning the project:

1. shift + cmd + k
2. shift + cmd + Alt + k 

Then try to run your project again. Hope this will fix the problem.

siburb
  • 4,880
  • 1
  • 25
  • 34
Rashed
  • 2,349
  • 11
  • 26
15

None of the popular solutions worked.
In my case, I resolved the error by going into the

XCode -> Preferences -> Accounts -> Manage Certificates

and added a (+) to iOS development.

zx485
  • 28,498
  • 28
  • 50
  • 59
vinyllover
  • 151
  • 1
  • 2
  • This works for me but I have to do it EVERY day. Argh. I wish I understood how to make this work for more than 24 hours. – Jamie M. Dec 16 '22 at 14:46
6

This issue happened to me after adding .dae and .png files and converting .dae with XCode Editor to SceneKit scene file format (.scn).

After doing some more research I found the solution here - https://forums.developer.apple.com/thread/109951#336225

Steps to solve the issue:

  1. In XCode go to Preferences
  2. Click on Locations tab
  3. In Command Line Tools select from the drop down XCode 10.1
plamenti
  • 109
  • 1
  • 4
5

In Xcode: Go to Preferences Logout of the current user.

Close Xcode

In Keychain: Go to Login and All items

        - Sort by kind
             - remove "Apple Worldwide Developer Relation Certification Authority"
             - remove "Developer ID Certification Authority"
             - remove "iPhone Developer ...."

Open Xcode

Go to Preferences and Login to you user apple account

  • This will reload your developer certificates you previous deleted Rebuild the project (Should be a successful build)

Run the build on your native device

Val
  • 1,260
  • 5
  • 23
  • 39
5

This is because 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, go to .app folder, normally is like: /Users/XXXX/Library/Developer/Xcode/DerivedData/MyProject-ckbzynxqjmstxigbdwwkcsozlego/Build/Products/Debug-maccatalyst/ (mine is Catalyst project) In Terminal,

cd <above path>
xattr -lr .

You will see some files has extended attribute:

./MyProject.app/Contents/Resources/shopping_cart.png: com.apple.lastuseddate#PS: 00000000 BE 31 D5 5E 00 00 00 00 D0 40 FE 39 00 00 00 00 |.1.^.....@.9....|

Then go to your project folder or referenced folder for those files, remove extended attribute:

cd /Users/XXXX/Work/MyProject
xattr -cr .

After clean all referenced folders, go to Xcode and rebuild.

Sam Xu
  • 252
  • 3
  • 5
3

The solution for me was restarting macOS without saving

Faustino Gagneten
  • 2,564
  • 2
  • 28
  • 54
2

I'm unsure of what causes this issue but one method I used to resolve the porblem successfully was to run pod update on my cocoa pods.

The error (for me anyway) was showing a problem with one of the pods signing. Updating the pods resolved that signing issue.

pod update [PODNAME] //For an individual pod

or

pod update //For all pods.

Hopefully, this will help someone who is having the same "Command CodeSign failed with a nonzero exit code" error.

paul_f
  • 1,296
  • 17
  • 20
  • I dont have a podfile - not sure evenwhat the filename and extension should be. Can u clearify? – Ride Sun Mar 04 '20 at 02:15
  • Hi @RideSun, You might not have added pods to your project yet. The podfile is litteraly called "Podfile". It has no extension, by default, it will be a TextEdit file. – paul_f Mar 04 '20 at 11:47
2

In my case was the following errors lines:

Signing Identity: "-"

…..mobile.app: resource fork, Finder information, or similar detritus not allowed

Command CodeSign failed with a nonzero exit code

the problem was that in the resources folder I had some files with .png extension, which was hidden on the defaults.

Find file in FINDER, mark it -> cmd+i -> unchek Hide extension

after that, return in Xcode -> kmd + shift + K and rebuild.

I hope I've been helpful!

Theo
  • 57,719
  • 8
  • 24
  • 41
Madji
  • 31
  • 4
2

For me the solution was the following, having the "Automatically manage sign" flag on:

  1. in the team drop-down of the target, select "None"

  2. re-select the correct development team

After trying almost every suggestion, I found that this works, I guess because Xcode sets up the signing stuff from scratch.

mr_dami
  • 81
  • 5
2

After trying everything, my solution was removing some PNG files, build and run (ok) and adding again the PNG images. Weird!

Nicoli
  • 643
  • 1
  • 7
  • 23
  • Similar thing. Added 5 .PNG files without a .PNG extension, the first few builds worked, then after editing controls in IB the above signing error occurred with the message "resource fork, Finder information, or similar detritus not allowed". Detritus? Who uses that word? By changing the names of the files to have the extension .PNG it fixed the problem. – Chris Walken May 21 '20 at 16:14
2

I will post my solution. This solution worked for me, since none of the previous worked. The issue first occurred right after last update of XCode cli toolset (not sure if this is the confirmation bias).

I tried some of the instructions (ie. Unlock Keychain Trick).

What worked for me in a case of error:

  • Command CodeSign failed with a nonzero exit code (Something.framework)

    • Trash DD Content; rm -rf /Users/dx/Library/Developer/Xcode/DerivedData/*
    • Restart XCode
    • Build Phases => Link Binary With Libraries
      • Something.framework,
    • Set embed value in General => Something.framework => EMBED
      • Do not embed
    • Press Cmd+B (Build Project)
    • Hopefully Built Successful
sensation
  • 437
  • 1
  • 5
  • 22
  • When I did above steps, I truly built the app successfully, but Xcode remind me: **reason: image not found**. I sovle the problem by the follow step: TARGETS - Build Phases - Link Binary With Framework - `Something.framework` - Status -> Optianl – Xuyee Wang Jun 09 '20 at 16:52
2

In my experience, the reason that caused this problem was I wrongly reset the Keychain Access to default, so I lost my development certificate.

How did I solve this?

  1. I cleaned my Apple Development Certificate from Keychain Access
  2. I cleaned my Apple Development private key from Keychain Access
  3. Then I got the new error : Revoke certificate Your account already has an Apple Development signing certificate for this machine, but its private key is not installed in your keychain. Xcode can create a new one after revoking your existing certificate.
  4. Go to Xcode Preference -> Accounts Tab -> Fine the team name under the Apple ID -> Double Click it -> Click the + button at the bottom left of box -> Select App Development
  5. In the team drop-down of the target, select "None"
  6. Re-select the correct development team
  7. Clean the project by shift+cmd+k
  8. Rebuild the project cmd+b
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Sheldon TT
  • 69
  • 8
1

I, too, saw this error after adding a mixture of .jpg and .png images to the art.scnassets folder, making code changes, and removing those changes via Xcode's Source Control > Discard All Changes... menu.

I tried the other fixes in this thread but, ultimately, I had to delete the added .jpg/.png files, clean the project, and rebuild the project to eliminate the errors. I then readded the original .jpg/.png files and I'm now rebuilding the code without issue.

hawtakshun
  • 79
  • 3
  • I have added several swift files from my other project and also one png image. After deleting that png image project build successfully – Prashant Gaikwad Mar 23 '19 at 06:34
1

For me I had to go to keychain, select the "login" keychain, double click on the iOS Developer:myname key, click the access control tab and switch the radio button to Allow all applications to access this item.

1

This problem was caused by building my project in the Release schema. It can be caused by other things as well. Try to switch the build schema by going in xCode to Product > Scheme > Edit Scheme. In the "Run" Section located on the left, switch the "Build Configuration" to "Debug". I hope this will help.

1

None of the above solutions worked for me. After some guess work, I tried (Xcode v10.2.1 cocoapods v1.7.1)

pod deintegrate

followed by

pod install

Then:

  • Opened the workspace in Xcode
  • Cleaned build folder
  • Build the project

No build errors.

ToddX61
  • 683
  • 6
  • 12
1

My Problem was solved

  • Check Automatically manage signing on Target MyProject and Add Team.
  • Check Automatically manage signing on Target MyProjectTest and Add Team.
  • Product -> Clean Build Folder -> Build again or try to run on device.

The problem occurs when you have the wrong/different team on MyProject and MyProjectTest.

Reconnecting your phone prior to rebuilding may also assist with fixing this issue.

MichaelStoddart
  • 5,571
  • 4
  • 27
  • 49
myturmudi
  • 201
  • 3
  • 8
1

It works for me by delete all the apple developer Certification in the keychain. and generate it in the Xcode.

Bruce
  • 1,688
  • 1
  • 12
  • 12
1

I was experiencing this issue due to the misconfiguration of my Apple Worldwide Developer Relations Certification Authority certificate.

I resolved issue by switching from "Alway Trust" to "Use System Defaults"

Step by Step:

  1. Open KeyChain
  2. Click on "login" keychain (make sure it's unlock - if it's locked Right Click on it and choose "Unlock KeyChain")
  3. Click on Certificates and locate Apple Worldwide Developer Relations Certification Authority certificate
  4. Right click on it and choose Get info
  5. Expand Trust section and change settings to Use System Defaults as per below screenshot

enter image description here

marika.daboja
  • 881
  • 13
  • 27
1

This issue can also occur when upgrade from XCODE 11.x to 12.0. After installation of new version of XCODE, restart system to overcome this issue.

iravinandan
  • 659
  • 6
  • 16
1

I fixed this issue only by renaming Resources folder (not group) to any other names such as Resource, Resources123, etc.

Michael
  • 415
  • 6
  • 16
1

I tried clearing XCode caches, all of the keychain stuff mentioned above, restarting XCode and nothing worked except... drum roll please...

Turning my Macbook off and back on again!!

This error has become a regular occurrence for me, always stemming from the Iterable SDK, but a quick reboot always fixes it

Shep Sims
  • 698
  • 9
  • 27
0

Not sure if this will help anyone - but make sure you have Find Implicit Dependencies checked off. Sometimes this can lead to your project "losing track" of where to look for certain things.


enter image description here


Once you do this, I suggest then also cleaning your project and rebuilding.

enter image description here

Zoe
  • 27,060
  • 21
  • 118
  • 148
Will Von Ullrich
  • 2,129
  • 2
  • 15
  • 42
0

None of other answers worked. This is what I have done:

  1. deleted my certificate from keychain;
  2. opened Xcode it rebuild certificate;
  3. ran app on device successfully.
brasofilo
  • 25,496
  • 15
  • 91
  • 179
Bhavesh Jain
  • 53
  • 1
  • 6
0

in my case it was a corrupted storyboard file

roberto
  • 577
  • 6
  • 5
0

After i copied two .aiff files in a .scnassets group, this error occured. Deletion of the files and a "Clean Build Folder" solves the problem in my case.

nik
  • 181
  • 1
  • 6
0

This worked for me :) I removed the certificate in keychain access settings. Go to Xcode and clean build the app. Now certificate is again created in keychain access and build gets succeeded with real device.

0

Just a visualisation

Lock Keychain "login" -> Unlock Keychain "login" -> Always allow

enter image description here

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
0

In my case it was an accidentally turned on option. I'm using common root .xcconfig files both for iOS and macOS, for the iOS target the Enable hardened runtime option remained on so replacing the line

ENABLE_HARDENED_RUNTIME = YES

by the

ENABLE_HARDENED_RUNTIME[sdk=macosx*] = YES

in the .xcconfig file solved the issue

Hofi
  • 945
  • 1
  • 6
  • 18
0

May sound stupid, but, try with no password, when it asked.

Tiago Gouvêa
  • 15,036
  • 4
  • 75
  • 81
0

For me the highest rated answer didn't work.

What did work was to go to Signing and Capabilities -> Team -> add account and add the Apple ID again.

After doing this, when I built again I was asked for my login credentials and the build succeeded.

0

I tried all of the above soloutions. none of them worked. I figured out that I had 2 keychains. Both of them had certificates and keys. I´ve deleted one keychain and removed all its key and certificates and just kept the "login" keychain. I´ve also removed everything from this keychain and then redownloaded the certificate from the apple developer page. After doing so everything was imported just into this ONE keychain. Cleaned Xcode, started. no problems!

tyler
  • 424
  • 4
  • 16
  • Where did you download the certificates from? If I don't have the paid certificates, can I do it too? – Paul Aug 21 '22 at 08:02
0

I had just added the SystemConfiguration.framework and Reachability h and m when the issue began. I tried all of these solutions and ended up removing systemConfiguration.framework and that fixed it for me. The Reachability h and m are still in the project.

Mick
  • 147
  • 9
0

What worked for me (Xcode 11.3.1 on Catalina 10.15.5.)

FYI - I have no team. I went to "Signing and Capabilities" for the build and the "Automatically manage signing" was already unchecked.

I checked it, which brought up a menu saying that it will reset some build settings. I clicked "Enable Automatic". Then I went back and unchecked the "Automatically manage signing" again to put it back to the way it was.

Worked after that.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Matt
  • 325
  • 3
  • 5
0

None of the bulk action solutions have worked for me. The extended attributes don't get removed. Each time this has happened for me it was a problem with one or more 3D models (.dae) or a .png file.

I have found that removing attributes (detritus) one file at a time works out to be faster in the end. I had to switch to the art.scnassets directory in terminal. (You can drag it from finder to terminal) For each suspect (new) file, I ran "xattr -lr filename.ext" to see if it had extended attributes. If so, I ran "xattr -cr filename.ext" to remove them. It has worked every time, but only by removing the attributes for each file. Then use Product - Clean Build Folder, and Build again. It has worked every time without fail.

0

Finaly!!

I guess xcode doesn't allow running an app on local iPhone if you are not using iOS Certificate! I had only Distribution certificate and everything was fine except this error when trying to run on local device. After I've made an iOS Developer certificate the issue went away

Vadim F.
  • 881
  • 9
  • 21
0

My case: I have removed the certificate, which is included on the profile.
My solution:

  • Remove all profile at: /Users/{yourusername}/Library/MobileDevice/Provisioning Profiles
  • Re-add profile.
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
0

What worked for me - found elsewhere - was very simple:

flutter clean

(run it in Terminal from the base dir of the project)

Note that Clean Project in XCode did not make a difference, tried that first.

Pieter
  • 2,621
  • 4
  • 19
  • 26
0

Amazingly, none of the 30 answers so far mentions the issue I faced and the corresponding solution. For me, the exact error message was errSecInternalComponent Command CodeSign failed with a nonzero exit code.

The error message appeared when running a command-line build from a remote (ssh) login. Running the same build command in the macOS desktop terminal window, caused a dialog box asking me for my password to pop up. After entering my password, the build succeeded.

Diomidis Spinellis
  • 18,734
  • 5
  • 61
  • 83
0

Added png file to my xcode project and saw this "blue screen":)

"Command CodeSign failed with a nonzero exit code. Xcode 14."

Deleted png and everything is ok. Magic.)

Vitalya
  • 166
  • 4
0

I opened "Keychain access" and deleted the expired certificates. Then did a build and this error disappeared.

Nitin
  • 29
  • 7
-3

In my case, some special marks in the png files output by Paint.app causes this happen.

My solution is

step 1. drag the png files(if you do not know which png, please drag all png files in your project resource folder/group) caused the error happens to Preview.app

enter image description here

step 2. adjust image size,

enter image description here

step 3. enlarge 2 times for width and height, click 'Ok' button

enter image description here

step 4. set back to original width and height, click 'Ok' button

enter image description here

step 5. repeat step 3 and step 4 for all png images

step 6. clean project and build again

Nimantha
  • 6,405
  • 6
  • 28
  • 69
arachide
  • 8,006
  • 18
  • 71
  • 134