ios Xcode 8 无法存档“命令 /usr/bin/codedesign failed with exit code 1”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39449665/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 10:06:44  来源:igfitidea点击:

Xcode 8 can't archive "Command /usr/bin/codesign failed with exit code 1"

iosxcodemacosbuildarchive

提问by Kee

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

我在 macOS Sierra 上的 Xcode 8 上遇到了严重问题。当我尝试构建我的应用程序时,出现以下问题。

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/48905in the terminal as the following and it worked. but once I clean, the issue comes back.

然后我在终端中做了https://forums.developer.apple.com/thread/48905如下所示并且它起作用了。但是一旦我清理干净,问题又回来了。

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

回答by DevManny

I found this solution in the Apple forum

我在 Apple 论坛中找到了这个解决方案

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

or

或者

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

回答by Sunil aruru

Solution 1:

解决方案1:

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

您可以尝试像 Mark McCorkle 回答的文件特定的 bash 命令。

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.

清理 Xcode 并重新构建。完毕。

Solution 2:

解决方案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

这将在当前目录中创建 kundapura.txt。现在搜索 com.apple.FinderInfo 并清除所有文件的此属性。你可以这样做

xattr -c <filename>
Example: xattr -c guru.png

Once you clear all then you are able to code sign. Cheers

清除所有内容后,您就可以进行代码签名了。干杯

回答by Gianluca

For me worked this:

对我来说是这样的:

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

And then rebuild

然后重建

回答by raeldor

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

对此有一个更永久的修复。修复 DerivedData 中的属性有效,但问题不断出现。您需要做的是转到“资源叉、Finder 信息或不允许的类似碎屑”时显示的目录,该目录包含 .App 文件。然后执行...

xattr -lr MyAppName.App

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

然后您可以看到具有需要删除的属性的资源文件。不要从 .App 文件中删除它们,在你的项目中找到原始文件并打开包含它们的目录并执行...

xattr -rc .

xattr -rc 。

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

然后修复原始文件。重建应该可以正常运行。然后它也应该为存档正确重建。

回答by Can Poyrazo?lu

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

这是由文件系统上具有额外属性的一些资源文件引起的,可能是由 macOS Sierra 引起的(因为我在升级到 macOS Sierra 后开始使用它)。

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

尝试xattr -c *在整个DerivedData文件夹上执行(如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 DerivedDatafolder fixed it for me in archiving too. Please note that it may cause other consequences (albeit highly unlikely), but you can always delete the DerivedDatafolder and it will be regenerated, in case anything gets broken.

仅在构建文件夹上删除属性为我解决了调试时的问题。删除整个DerivedData文件夹的属性也为我在归档中修复了它。请注意,它可能会导致其他后果(尽管可能性很小),但您始终可以删除该DerivedData文件夹,并且它会重新生成,以防万一发生任何损坏。

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

此外,如果它仍然失败,在执行命令后清理项目(而不是构建文件夹)是个好主意。

回答by Andrew Romanov

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

我在 CocoaPods 包中的一个文件中遇到了这个问题。我已将 CocoaPods 更新到最新版本并运行:

pod install

after that, the problem has gone away.

在那之后,问题就消失了。

回答by Spydy

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. Xcode Preferences ->Accounts->Delete 已经添加的账号再添加
  2. 生成新的 Provisioning Profiles 并安装在 Xcode 中
  3. 清理项目并重建它

回答by Markus

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

我在 iOS 应用程序中添加了一个新目标:iMessage

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

当我将 png 图像添加到 Assets 时。xcassets,发生错误。

Solution:

解决方案:

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

使用“Apple Preview App”制作png图像的副本并取消选中Alpha。

Preview App screenshot

预览 App 截图

Error message disappears.

错误信息消失。

Preview App screenshot

预览 App 截图

回答by Blaszard

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

有时,即使您修复和/或完成了正确的代码签名,问题也可能潜伏在 3rd-party package 中

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

如果您仔细检查构建错误,您可能会在错误消息中找到第 3 方库的名称。

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

在这种情况下,您必须再次构建您的第 3 方库。例如,在我的情况下,通过更新它carthage update,现在构建成功成功。

回答by Gajendra K Chauhan

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

  • Xcode 偏好

  • 地点

  • 单击项目路径箭头

  • 在 DerivedData 文件夹中搜索您的项目名称

  • 选择项目文件夹,右键单击并移至垃圾箱

Done!

完毕!