xcodebuild /usr/bin/codesign unknown error -1=ffffffffffffffff

jenkins 脚本打包报

unknown error -1=ffffffffffffffff

  /usr/bin/codesign '--force' '--sign' '***********' '--verbose' '/Users/Shared/Jenkins/Home/workspace/***/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/***/InstallationBuildProductsLocation/Applications/***.app/Frameworks/libswiftAVFoundation.dylib'
/Users/Shared/Jenkins/Home/workspace/***/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/***/InstallationBuildProductsLocation/Applications/***.app/Frameworks/libswiftAVFoundation.dylib: unknown error -1=ffffffffffffffff
error: Task failed with exit 1 signal 0 {
    /usr/bin/codesign '--force' '--sign' '****************' '--verbose' '/Users/Shared/Jenkins/Home/workspace/***/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/***/InstallationBuildProductsLocation/Applications/***.app/Frameworks/libswiftAVFoundation.dylib'

看了使用的证书和配置文件都是对的,clean xcode,重启电脑 都不起作用。如果用 xcode 直接打包也是好的,直接 codesign 这个libswiftAVFoundation.dylib 也不报错。 google 好久也没找到原因,最后想了想既然是 codesign 报错,那么直接把证书删除,重新导入一遍,再打包居然就** ARCHIVE SUCCEEDED **了。

但是后面还是有一个错** EXPORT FAILED **

error: exportArchive: exportOptionsPlist error for key 'method': expected one of {}, but found enterprise

Error Domain=IDEFoundationErrorDomain Code=1 "exportOptionsPlist error for key 'method': expected one of {}, but found enterprise" UserInfo={NSLocalizedDescription=exportOptionsPlist error for key 'method': expected one of {}, but found enterprise}

这个 google 后,参考 :https://stackoverflow.com/questions/32841300/xcodebuild-exportarchive-exportoptionsplist-error-for-key-method-expected-o ,上面的最高票答案说的也是不明所以,但是下面有一个答案是这样写的

I had the same issue since two days, The issue came from Apple certificates. Delete Apple Worldwide Developer Relations certification Authority from your keychain (would be expired at 14 Feb) and so renew it by download :

[https://developer.apple.com/news/?id=02092016a](https://developer.apple.com/news/?id=02092016a)

虽然我的 Apple Worldwide Developer Relations certification 还有好几年才过期,但是实在没办法了就试试看,居然成功了。

天真的以为就这样就好了。但是呢刚过了一天,又打包失败了,还是同一个错误。这次 经过仔细思考,开始怀疑 是否打包的时候,是否是 询问 钥匙串密码导致的,因为 加了 swift 之后,代码编译时间变长,虽然 编译之前有 解锁 钥匙串的脚本,会不会是时间太长又锁住了呢?

于是 赶紧 google ,添加了 设置过期时间的脚本,链接https://stackoverflow.com/questions/41680511/jenkins-where-is-the-login-keychain-file-in-users-name-library-keychains-fol

# 设置过期时间
security set-keychain-settings -t 3600 -l ${HOME}/Library/Keychains/login.keychain

经过几分钟的等待,打包终于又好了。哎,希望这次能坚持的久一点 不再报错了。

真心无力吐槽 苹果的报错原因,经常报错不说,原因还不知所以。

最后附上 命令行 导入 钥匙串的命令

# 解锁钥匙串
security unlock-keychain -p  *password* login.keychain-db

# 删除
security delete-certificate -Z 证书identifier

# 导入p12
security import *.p12 -k login.keychain-db -P *password* -T /usr/bin/codesign

# 查看导入的证书
security find-identity -p codesigning login.keychain-db

你可能感兴趣的:(xcodebuild /usr/bin/codesign unknown error -1=ffffffffffffffff)