使用无人值守的 xcodebuild 管理钥匙串以协同设计 macOS / iOS 应用程序

Geo*_*rge 2 macos code-signing xcodebuild ios

我需要每天午夜创建我的 macOS 应用程序版本。我希望它是代码签名的,这样人们就可以使用它而无需跳过箍。我在午夜睡着了,我太忙了,无法手动执行此操作。我想通过启动代理运行 xcodebuild 并在远离键盘的情况下获得一个签名的应用程序。但是代码签名总是失败。

它失败并出现以下错误:

No signing certificate "Mac Development" found:  No "Mac Development" signing certificate matching team ID "H7V7XYVQ7D" with a private key was found.
Run Code Online (Sandbox Code Playgroud)

当我观看时它不会失败,这意味着它必须与钥匙串锁定本身有关。不久前我试图解决这个问题,但没有运气:

但没有任何作用。这甚至可能吗?

abl*_*arg 5

export tempKeychain=tempKeychain
export identity="iPhone Whatever: Bob Developer(132455334)"

# create new empty keychain
security create-keychain -p "${ADMIN_PASSWORD}" "${tempKeychain}"

# add keychain to user's keychain search list so they can access it
security list-keychains -d user -s "${tempKeychain}" $(security list-keychains -d user | tr -d '"')

# removing relock timeout on keychain
security set-keychain-settings "${tempKeychain}"

# import the certs
security import foo.p12 -k "${tempKeychain}" -P "${CERT_PASSWORD}" -T "/usr/bin/codesign"

# tell os it's ok to access this identity from command line with tools shipped by apple (suppress codesign modal UI)            
security set-key-partition-list -S apple-tool:,apple: -s -k "$ADMIN_PASSWORD" -D "${identity}" -t private ${tempKeychain}

# set default keychain to temp keychain
security default-keychain -d user -s ${tempKeychain}

# unlock keychain
security unlock-keychain -p ${ADMIN_PASSWORD} ${tempKeychain}

# prove we added the code signing identity to the temp keychain
security find-identity -v -p codesigning

# do some codesign stuff

# clean up temp keychain we created
security delete-keychain ${tempKeychain}
Run Code Online (Sandbox Code Playgroud)

您是否考虑过让 launchd 脚本使用 ssh -o 到 localhost 来像 CI 服务器(例如 Jenkins)那样运行命令?