2016-09-12 43 views
44

我在macOS Sierra上遇到了嚴重的問題。 當我嘗試構建我的應用程序時,出現以下問題。Xcode 8無法歸檔「command/usr/bin/codesign失敗,退出代碼1」

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 

然後我在終端做了https://forums.developer.apple.com/thread/48905,如下所示。但一旦我清理乾淨,問題就會回來。

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

ls [email protected] * 

xattr -c * 

並且此解決方案不適用於以下問題存檔。有沒有解決方案?

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 
+0

您是否找到了解決辦法?大約兩週前我下載了Xcode 8,並與它簽署了相同的應用程序。幾天前我已經安裝了macOS Sierra(之前我曾經使用過El Capitan),現在它並沒有簽署相同的應用程序。 –

+0

同樣在這裏,這讓我瘋狂。只有當我有一個CocoaPods項目纔會發生。 – noisedan

+1

@noisedan沒有CocoaPods在這裏,也有問題。我不認爲它與豆莢有關。但似乎項目具體。例如,這發生在我的MacOS應用程序中,沒有任何豆莢,但我有一個帶有豆莢的iOS應用程序,它的簽名完美。 –

回答

6

這得到由具有文件系統,可能是由塞拉利昂的MacOS造成了額外的屬性一些資源文件引起的(因爲我一開始升級到MacOS的塞拉利昂之後有它)。

嘗試對整個DerivedData文件夾執行xattr -c *(如https://forums.developer.apple.com/message/178039#178039由回答說):

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

刪除只在build文件夾屬性進行調試時,固定我的問題。整個刪除屬性DerivedData文件夾也修復了我的歸檔。請注意,它可能會導致其他後果(儘管極不可能),但您可以隨時刪除DerivedData文件夾,並且它會被重新生成,以防萬一有任何破壞。

另外,如果仍然失敗,執行該命令後清理該項目(而不是 build文件夾)是個不錯的主意。

+0

感謝您解釋 - 總是更好地理解正在發生的事情,而不是盲目複製粘貼終端命令。 –

108

我發現在蘋果論壇上該解決方案

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

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

爲我工作.. – Clement

+1

誰是誰發現這個天才?非常感謝! – Dmitry

+1

這也適用於我。你是一個救星!我花了幾個小時。 – Jackson

12

工作對我來說這樣的:

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

,然後重建

+0

在macOS Sierra上爲我工作。謝謝! – pdesantis

+0

也爲我工作(macOS Sierra)。謝謝.. –

+0

節電器給我。我嘗試了一切。運行'xattr -c *'也沒有幫助。 – Rajal

20

解決方案1:

你可以嘗試文件特定的bash命令,如Mark McCorkle回答。

在終端,轉到項目的根目錄,然後執行一個個命令

find . -type f -name '*.jpeg' -exec xattr -c {} \; 
    find . -type f -name '*.png' -exec xattr -c {} \; 
    find . -type f -name '*.tif' -exec xattr -c {} \; 

清潔Xcode和重新構建。完成。

解決方案2:

您可以通過尋找持有取景器信息文件解決這個問題。

在終端,轉到項目根目錄,並執行

ls [email protected] . > kundapura.txt 

這當前目錄中創建kundapura.txt。現在搜索com.apple.FinderInfo並清除所有文件的這些屬性。你可以這樣做

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

一旦你清除所有,那麼你可以編碼的跡象。乾杯

+1

解決方案1 ​​ - 爲我工作。謝謝! –

+1

第一個解決方案在macOS Sierra上爲我工作。這是**。png **文件的問題。非常感謝! – JonyMateos

+0

解決方案1也適用於我。此列表中沒有其他內容 –

3

我有這個問題,從CocoaPods包中的一個文件。 我已經更新的CocoaPods到最新版本,並運行:

pod install 

,這個問題已經消失。

+1

這樣做然後運行Cmd + shift + k(即清理)在我的項目在Xcode爲我工作 –

9

有一個更永久的解決方案。修復DerivedData中的屬性的作用,但問題不斷回來。當你得到'資源分叉,Finder信息或不允許的類似碎片'時,你需要做的是進入顯示的目錄,該目錄包含.App文件。然後執行...

XATTR -lr MyAppName.App

然後,您可以看到,有需要移除的屬性的資源文件。不要從.App文件中刪除它們,找到項目中的原始文件並打開包含它們的目錄並執行...

xattr -rc。

然後修復原始文件。然後重建應該運行正常。它也應該也適用於檔案重建。

+0

這是唯一建議在這裏工作對我來說!謝謝! – rozmichelle

+1

爲我工作。罪魁禍首文件在Images.xcassets文件夾中的圖標文件的位置。 –

+0

當我運行'xattr -lr MyAppName.app'時,什麼都沒有列出 – arnoldbird

0

在我的情況下,

轉到

  • Xcode的偏好

  • 位置

  • 點擊項目路徑箭頭

  • 在DerivedData文件夾中搜索自己項目AME

  • 選擇項目文件夾,右擊並移至回收站

完成!

0

我在macOS Sierra 10.12.3,Xcode 8.2上遇到了這個錯誤。 修復DerivedData不適用於我。

之後我刪除過期蘋果全球開發者關係的證書頒發機構證書鑰匙串訪問錯誤就走開了。

2
在我的情況的問題

與部署配置文件和帳戶,我固定通過執行下列步驟操作:

  1. Xcode的首選項 - > Accounts->刪除已添加的帳戶,再
  2. 添加它生成新的部署配置文件並安裝在Xcode
  3. 清潔工程,甚至重建它
+1

我有這個相同的問題。當我在帳戶中看到時,它告訴我會話過期登錄再次。 –

0

有時候,如果你固定的和/或有正確的代碼簽名完成,日e問題可能潛伏在第三方軟件包中。

如果您仔細檢查出構建錯誤,可能會在錯誤消息中找到第三方庫的名稱。

在這種情況下,您必須重新構建您的第三方庫。例如在我的情況下,通過carthage update進行更新,現在構建成功。

2

我想告訴我的答案,因爲它可能有興趣(我也浪費了大量的時間與這個錯誤)前面的答案(具有高得分)的

Error screenshot

都沒有對我有用。

他們可能是正確的,但他們還沒有解決我的問題。

來源:

我添加了一個新的目標,以我的iPhone應用程序:iMessage的

當我將PNG圖像的資產。 xcassets,發生錯誤。

解決方案:

請與「蘋果Preview應用」 PNG圖像的副本,並取消阿爾法。

Preview App screenshot

錯誤信息消失。

Preview App screenshot

+0

這真的很有幫助。解決了我的問題:)快樂的編碼。 – PJR

相關問題