ChatGPT解决这个技术问题 Extra ChatGPT

Xcode 10, Command CodeSign failed with a nonzero exit code

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.


C
Community

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

I solved with these steps:

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

And after that everything works fine.


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
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
It takes me half a day until I found your solution that saved me, thank you dear friend.
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.
@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
P
Paul Slocum

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.


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.
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.
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.
can someone please tell me where and how I can find this resource folder
@pratteekshaurya It would be a folder that you created within your project
s
snibbe

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


searching weeks for the issue and asking Apple for support - without success. Thanks for your solution ! Works perfect for me - for SEVERAL projects.
Cheers for this. Fixed my issue.
Replacing with the path to your actual app bundle.
J
Jonas

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.


Had this same issue with a .jpg, that didn't have it extension. Fixed after adding that.
Thanks for saving me time. Kudos for relating that error to an image with a hidden extension.
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.
same problem here with PNG image!
This worked for me - thank you - I can confirm this bug has not been fixed on Xcode 11.5 (11E608c)
r
rjobidon

Fix

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

Open Terminal Change directory to the root of your source files $ cd /Users/rjobidon/Documents/My\ Project List all extended attributes

$ xattr -lr .

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

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


I was trying to enable iOS app into Mac Catelist app and this fixed the issue. Thanks
my xaddr on Mac doesn't have "c" option, so I just did "xaddr -d ." and it also solved the problem
xattr -rc Solved my problem.
s
siburb

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.


Did. clean succeeded. when i build i's failing
build failing bro.
Worked as a charm in my case!
z
zx485

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.


p
plamenti

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:

In XCode go to Preferences Click on Locations tab In Command Line Tools select from the drop down XCode 10.1


V
Val

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


S
Sam Xu

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.


F
Faustino Gagneten

The solution for me was restarting macOS without saving


p
paul_f

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.


I dont have a podfile - not sure evenwhat the filename and extension should be. Can u clearify?
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.
T
Theo

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!


I tried the other solutions. This is the only solution that worked for me.
m
mr_dami

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

in the team drop-down of the target, select "None" 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.


N
Nicoli

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


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

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

Trash DD Content; rm -rf /Users/dx/Library/Developer/Xcode/DerivedData/*

Restart XCode

Build Phases => Link Binary With Libraries Something.framework,

Something.framework,

Set embed value in General => Something.framework => EMBED Do not embed

Do not embed

Press Cmd+B (Build Project)

Hopefully Built Successful


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
J
Jason Aller

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?

I cleaned my Apple Development Certificate from Keychain Access I cleaned my Apple Development private key from Keychain Access 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. 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 In the team drop-down of the target, select "None" Re-select the correct development team Clean the project by shift+cmd+k Rebuild the project cmd+b


h
hawtakshun

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.


I have added several swift files from my other project and also one png image. After deleting that png image project build successfully 😀
P
Patrick Duchesneau

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.


A
Abdulmohsen Alabra

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.


T
ToddX61

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.


M
MichaelStoddart

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.


m
marika.daboja

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:

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

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


i
iravinandan

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.


b
brasofilo

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

deleted my certificate from keychain; opened Xcode it rebuild certificate; ran app on device successfully.


r
roberto

in my case it was a corrupted storyboard file


n
nik

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.


Z
Zoe stands with Ukraine

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.

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

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

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


S
Swetha Reddy

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.


y
yoAlex5

Just a visualisation

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

https://i.stack.imgur.com/6zRr3.png


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now