Xcode 8无法归档"Command/usr/bin/codesign失败,退出代码为1"

Kee*_*Kee 45 macos xcode build archive ios

我在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
Run Code Online (Sandbox Code Playgroud)

然后我在终端上做了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 *
Run Code Online (Sandbox Code Playgroud)

并且此解决方案不适用于具有以下问题的存档.它有什么解决方案吗?

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
Run Code Online (Sandbox Code Playgroud)

Dev*_*nny 109

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

cd ~/Library/Developer/Xcode/DerivedData
xattr -rc .
Run Code Online (Sandbox Code Playgroud)

要么

xattr -rc ~/Library/Developer/Xcode/DerivedData
Run Code Online (Sandbox Code Playgroud)

  • 在Xcode 8.1和mac sierra上也为我工作过.谢谢! (3认同)
  • 修复了我在macOS Sierra,XCode 8.2上构建的破坏的Jenkins. (2认同)
  • 有效!如果有人想知道它的作用 - 它是扩展属性 (xattr) 的递归 (-r) 清除 (-c)。 (2认同)

Sun*_*uru 21

解决方案1:

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

在终端中,转到项目的根目录并逐个执行命令

  find . -type f -name '*.jpeg' -exec xattr -c {} \;
  find . -type f -name '*.png' -exec xattr -c {} \;
  find . -type f -name '*.tif' -exec xattr -c {} \;
Run Code Online (Sandbox Code Playgroud)

清理Xcode和重新构建.完成.

解决方案2:

您可以通过查找包含查找程序信息的文件来解决此问题.

在终端中,转到项目根目录并执行

ls -alR@ . > kundapura.txt
Run Code Online (Sandbox Code Playgroud)

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

xattr -c <filename>
Example: xattr -c guru.png
Run Code Online (Sandbox Code Playgroud)

一旦你清除了所有,那么你就可以编码.干杯


Gia*_*uca 12

对我来说,这是:

cd ~/Library/Developer/Xcode/DerivedData
xattr -dr com.apple.FinderInfo *
Run Code Online (Sandbox Code Playgroud)

然后重建


rae*_*dor 9

对此有一个更永久的解决方案.修复DerivedData中的属性,但问题仍然存在.您需要做的是当您获得"资源分支,Finder信息或类似的不允许的碎片"时,转到显示的目录,包含.App文件的目录.然后执行......

xattr -lr MyAppName.App

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

xattr -rc.

然后修复ORIGINAL文件.然后重建应该正常运行.然后它也应该正确地重建以进行存档.


Can*_*ğlu 6

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

尝试xattr -c *在整个DerivedData文件夹上执行(如https://forums.developer.apple.com/message/178039#178039中的答案所述):

cd ~/Library/Developer/Xcode/DerivedData
xattr -c *
Run Code Online (Sandbox Code Playgroud)

仅在构建文件夹中删除属性修复了调试时的问题.删除整个DerivedData文件夹中的属性也可以在归档中修复它.请注意,它可能会导致其他后果(虽然极不可能),但您可以随时删除该DerivedData文件夹,并在发生任何损坏时重新生成.

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