46

I've got a serious problem on Xcode 8 on macOS Sierra. when I try to build my app, I get the following issue.

CodeSign /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Products/Debug-iphonesimulator/MyApp.app
cd /Users/me/Desktop/MyAppFolder1/MyAppFolder2/MyAppxcode
export CODESIGN_ALLOCATE=/Users/me/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Users/me/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Users/me/Downloads/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

Signing Identity:     "-"

/usr/bin/codesign --force --sign - --timestamp=none /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Products/Debug-iphonesimulator/MyApp.app

/Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Products/Debug-iphonesimulator/MyApp.app: resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1

then I did https://forums.developer.apple.com/thread/48905 in the terminal as the following and it worked. but once I clean, the issue comes back.

cd /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Products/Debug-iphonesimulator/MyApp

ls -al@ *

xattr -c *

and this solution doesn't work for archive with the following issue. is there any solution for it?

CodeSign /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app
cd /Users/me/Desktop/MyAppFolder1/MyAppFolder2/MyAppxcode
export CODESIGN_ALLOCATE=/Users/me/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Users/me/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Users/me/Downloads/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

Signing Identity:     "iPhone Developer: My Name (**********)"
Provisioning Profile: "iOS Team Provisioning Profile: com.**********.*********"
                  (********-****-****-****-************)

/usr/bin/codesign --force --sign **************************************** --entitlements /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/MyApp.app.xcent --timestamp=none /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app

/Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app: resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1
8
  • have you found any solution to this? I downloaded Xcode 8 about 2 weeks ago and signed the very same app with it. a few days ago I've installed macOS Sierra (I had El Capitan before) and now it's not signing the same app. Commented Sep 23, 2016 at 5:40
  • Same here, this is driving me crazy. It's only happens if I have a project with CocoaPods.
    – noisedan
    Commented Sep 23, 2016 at 5:42
  • 1
    @noisedan no CocoaPods here, also having the problem. I don't think it's related to pods. but it seems project specific. for instance, this is happening to me on my macOS app with no pods, but I have an iOS app with pods and it's signing perfectly. Commented Sep 23, 2016 at 5:43
  • Check TimeVision response here, worked for me forums.developer.apple.com/thread/48905
    – noisedan
    Commented Sep 23, 2016 at 5:55
  • @noisedan it solved my issues on debug builds, but now I'm having the exact same problem as the OP: it's failing when I try to archive (which I have to in order to submit to app store) Commented Sep 23, 2016 at 6:00

11 Answers 11

112

I found this solution in the Apple forum

cd ~/Library/Developer/Xcode/DerivedData
xattr -rc .

or

xattr -rc ~/Library/Developer/Xcode/DerivedData
5
  • 3
    Worked for me too on Xcode 8.1 and mac sierra. Thank you! Commented Nov 29, 2016 at 6:32
  • 1
    This worked but I have to do this everytime I create a new app in XCode!
    – Mike Flynn
    Commented Dec 27, 2016 at 0:21
  • 2
    Fixed my broken Jenkins build on macOS Sierra, XCode 8.2.
    – Matt
    Commented Feb 8, 2017 at 17:17
  • 2
    It worked! If anyone wonders what it does - it's a recursive (-r) clear (-c) of Extended Attributes (xattr).
    – Fengson
    Commented May 9, 2017 at 13:29
  • 1
    This should be the accepted answer. It seems to be the only solution that's working for most everyone that tries it. Could you also post the link to the Apple Forums page?
    – Nathan F.
    Commented May 30, 2017 at 2:16
21

Solution 1:

You can try file specific bash command like Mark McCorkle answered.

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 '*.png' -exec xattr -c {} \;
  find . -type f -name '*.tif' -exec xattr -c {} \;

Clean Xcode and Re Build. Done.

Solution 2:

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 you are able to code sign. Cheers

2
  • 1
    The first solution worked for me on macOS Sierra. It was a problem with the .png files. Thanks a lot!
    – JonyMateos
    Commented Jan 18, 2017 at 16:03
  • Solution 1 worked for me as well. Nothing else in this list
    – Z. Zepos
    Commented Jul 31, 2017 at 19:50
12

For me worked this:

cd ~/Library/Developer/Xcode/DerivedData
xattr -dr com.apple.FinderInfo *

And then rebuild

1
  • Saver for me. I tried everything. Running xattr -c * also didn't helped.
    – Rajal
    Commented Mar 30, 2017 at 6:10
9

There is a more permanent fix for this. Fixing the attributes in the DerivedData works, but the problem keeps coming back. What you need to do is go to the directory shown when you get the 'resource fork, Finder information, or similar detritus not allowed', the one that contains the .App file. Then execute...

xattr -lr MyAppName.App

You can then see the resource files that have the attributes that need removing. Don't remove them from the .App file though, find the original files in your project and open the directory that contains them and execute...

xattr -rc .

This then fixes the ORIGINAL files. Rebuild should then function ok. It should also then rebuild properly for archive too.

3
  • this is the only thing suggested here that worked for me! thank you! Commented Apr 5, 2017 at 5:42
  • 1
    Worked for me. Culprit files where the icon files in Images.xcassets folder. Commented Apr 12, 2017 at 15:55
  • Nothing was listed when I ran xattr -lr MyAppName.app
    – arnoldbird
    Commented Feb 13, 2018 at 17:29
6

This gets caused by some resource files having extra attributes on the file system, probably caused by macOS Sierra (as I started having it after upgrading to macOS Sierra).

Try executing xattr -c * on the whole DerivedData folder (as stated by the answer in https://forums.developer.apple.com/message/178039#178039):

cd ~/Library/Developer/Xcode/DerivedData
xattr -c *

Removing attributes only on the build folder fixed the issue for me when debugging. Removing attributes on the whole DerivedData folder fixed it for me in archiving too. Please note that it may cause other consequences (albeit highly unlikely), but you can always delete the DerivedData folder and it will be regenerated, in case anything gets broken.

Also, if it still fails, cleaning the project (not the build folder) after executing the command is a good idea.

1
  • Thanks for explaining - always better to understand what is going on, rather than blindly copy pasting a terminal command. Commented Nov 7, 2016 at 11:26
4

I had this problem with one file from CocoaPods bundle. I've updated CocoaPods to the latest version and run:

pod install

after that, the problem has gone away.

1
  • 1
    Doing this then running Cmd+shift+k (i.e., clean) on my project in Xcode worked for me
    – Q A
    Commented Jul 22, 2017 at 23:30
3

in my case issue was with Provisioning Profiles and Account, i fixed by doing these steps:

  1. Xcode Preferences ->Accounts->Delete already added account and add it again
  2. Generate new Provisioning Profiles and installed in Xcode
  3. clean project and rebuild it
1
  • 1
    I had this same issue. When I saw in Accounts, it told me session expired login again. Commented Mar 29, 2017 at 0:55
2

I want to show my answer because it may be of interest (I have wasted a lot of time with this error)

Error screenshot

None of the previous answers (which have a high score) have been useful to me.

They may be correct, but they haven't solved my problem.

Origin:

I added a new Target to my iOS application: iMessage

When I added png images to the Assets. xcassets, the error occurred.

Solution:

Make a copy of png images with "Apple Preview App" and uncheck Alpha.

Preview App screenshot

Error message disappears.

Preview App screenshot

1
  • it is really helpful. Solved my issue :) Happy coding.
    – PJR
    Commented Nov 6, 2017 at 13:00
0

In my case,

Go to

  • Xcode preference

  • Locations

  • Click on Project Path arrow

  • In DerivedData folder search for your project name

  • Select project folder, Right click and Move to trash

Done!

0

I encountered this error on macOS Sierra 10.12.3, Xcode 8.2. Fixing the DerivedData did not work for me.

After I deleted an expired Apple Worldwide Developer Relations Certificate Authority certificate in Keychain Access the error went away.

0

Sometimes even if you fixed and/or had correct code-signing done, the problem might lurk in 3rd-party packages.

If you closely check out your build error, you might find the name of the 3rd-party libraries on the error message.

In this case, you must build your 3rd-party libraries again. For example in my case, update it via carthage update and now the build succeeded properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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