简体   繁体   English

无法远程构建Xcode项目

[英]Unable to remote build xcode project

I have a jenkins server connecting to a remote mac mini through ssh to execute a shell script that has to build an IPA from a unity project. 我有一台jenkins服务器通过ssh连接到远程Mac mini,以执行必须从统一项目构建IPA的外壳程序脚本。

When the shell script is executed locally on the mac mini everything goes fine. 当在Mac mini上本地执行shell脚本时,一切正常。 But when the shell script is ran from jenkins (with the exact same parameter and the same user) it fails codesigning the archive. 但是,当从jenkins(具有完全相同的参数和相同的用户)运行shell脚本时,它将无法对存档进行代码签名。

I will share with you the obfuscated shell script as well as the build log. 我将与您分享混淆的Shell脚本以及构建日志。

Thank you for your help in advance. 提前谢谢你的帮助。

The shell script : shell脚本:

#!/bin/bash

# Consider directory paths initialized in parameter here
#
#
# Consider git cleaning / fetching commit here
#
#
# Consider environment / version and build name controls here
#
#
# Start Unity Build :

/Applications/Unity2017.4.10f1/Unity.app/Contents/MacOS/Unity -batchmode -quit -projectPath "$SOURCE_PATH" -executeMethod "BuildManager.BuildPlayer" -logFile "$BUILD_LOG_FILE" -buildEnvironment "$ENVIRONMENT" -buildPlatform "IOS" -buildPath "$TARGET_BUILD_DIR" -overrideVersion "$OVERRIDE_VERSION"

if [ ! -d "${TARGET_BUILD_DIR}/Unity-iPhone.xcodeproj" ]
then
    echo "[ERR]Exporting unity project to Xcode failed."
    exit 1
else
    echo "Build successfull"
fi
#
#
# Consider initializing a param for the provisioning profile file path
#
#
# Consider initializing a param for the plist file path

cd $TARGET_BUILD_DIR

# archive generated xcode project    
xcodebuild -scheme "Unity-iPhone" -archivePath "${DEPLOY_DIR_ROOT}/${BUILD_NAME}_${FILE_FORMAT_VERSION}/archive.xcarchive" -sdk iphoneos -configuration Release PROVISIONING_PROFILE="${PROVISIONING_PROFILE_PATH}" archive

if [ $? != 0 ]; then
    echo "FAILED ARCHIVING XCODE PROJECT"
    exit 1
fi

# export ipa from archive
xcodebuild -exportArchive -archivePath "${DEPLOY_DIR_ROOT}/${BUILD_NAME}_${FILE_FORMAT_VERSION}/archive.xcarchive" -exportOptionsPlist "${PLIST_PATH}" -exportPath "${DEPLOY_DIR_ROOT}/${BUILD_NAME}_${FILE_FORMAT_VERSION}"

if [ $? != 0 ]; then
    echo "FAILED EXPORTING IPA FROM ARCHIVE"
    exit 1
fi
#
# Section reserved for uploading the ipa to relevant remote storage
#
exit 0

So everything works like a charm (even the build can be installed on a device) when the shell script is ran locally from the terminal on the mac mini. 因此,当从Mac mini的终端本地运行shell脚本时,一切工作都像一个魅力(甚至可以将构建版本安装在设备上)。

When it comes to run the shell script remotely through ssh it fails to codesign the archive. 通过ssh远程运行shell脚本时,无法对归档文件进行代码签名。 The user used over ssh is the same than the one used locally to run the script. 在ssh上使用的用户与在本地运行脚本的用户相同。

Here is the error : 这是错误:

CodeSign /#######/Library/Developer/Xcode/DerivedData/Unity-iPhone-#########/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/#########.app (in target: Unity-iPhone) cd /#########/xcodeProjPath export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate CodeSign / ###### /库/开发人员/Xcode/DerivedData/Unity-iPhone-########/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProducts位置/应用程序/ ## #######。app(位于目标:Unity-iPhone中)cd / ######### / xcodeProjPath export CODESIGN_ALLOCATE = / Applications / Xcode.app / Contents / Developer / Toolchains / XcodeDefault.xctoolchain / usr / bin / codesign_allocate

Signing Identity: "#########" Provisioning Profile: "iOS Team Provisioning Profile: #########" (#########) 签名身份:“ #########”配置文件:“ iOS Team配置文件:########”(#########)

/usr/bin/codesign --force --sign ######### --entitlements /#########/Library/Developer/Xcode/DerivedData/Unity-iPhone-#########/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/#########.app.xcent --timestamp=none /#########/Library/Developer/Xcode/DerivedData/Unity-iPhone-#########/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/#########.app /#########/Library/Developer/Xcode/DerivedData/Unity-iPhone-#########/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/#########.app: errSecInternalComponent / usr / bin / codesign --force --sign ######### --entitlements / ########## / Library / Developer / Xcode / DerivedData / Unity-iPhone-### ###### / Build / Intermediates.noindex / ArchiveIntermediates / Unity-iPhone / IntermediateBuildFilesPath / Unity-iPhone.build / Release-iphoneos / Unity-iPhone.build / ##########。app.xcent --timestamp = none /#########/Library/Developer/Xcode/DerivedData/Unity-iPhone-########/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/ InstallationBuildProducts位置/应用程序/#########.app / ######### / Library / Developer / Xcode / DerivedData / Unity-iPhone-######## / Build / Intermediates.noindex / ArchiveIntermediates / Unity-iPhone / InstallationBuildProductsLocation / Applications / #########。app:errSecInternalComponent

Command CodeSign failed with a nonzero exit code 命令CodeSign失败,退出代码非零

** ARCHIVE FAILED ** **归档失败**

I m kind of stuck right now since all my attempts didn't work at all ... Thank you in advance for your help. 我现在有点卡住,因为我的所有尝试都根本没有用...预先感谢您的帮助。

EDIT: 编辑:

mac mini on macOS High Sierra Version 10.13.6 (17G65) macOS High Sierra版本10.13.6(17G65)上的mac mini

xcode Version 10.0 (10A255) xcode版本10.0(10A255)

Ok so for all of you guys struggling around this tricky subject ( totally invisible if we don't know enough about macOS ) there is kind of security system that still makes the difference between a local user and a remote access to a user. 好的,对于所有在这个棘手的主题上苦苦挣扎的人(如果我们对macOS不够了解,这是完全不可见的),还有一种安全系统仍然可以在本地用户和远程访问用户之间发挥作用。

So the keychain handling your keys and certificates ( used by codesign to sign your build ) is not usable out of the box for the remote user. 因此,远程用户无法使用开箱即用的用于处理您的密钥和证书的密钥链(由codesign用来对您的构建进行签名)。 Its needs to be unlocked first !!! 它需要首先解锁!

To know about the available keychains on your system just type in on your terminal : 要了解系统上可用的钥匙串,只需在终端上输入:

security list-keychains 安全列表钥匙串

You should see something like : 您应该看到类似:

"/Users/'YOURUSER'/Library/Keychains/login.keychain-db"
"/Library/Keychains/System.keychain"

And you guessed it right there, you have to unlock the keychain of your user ! 您就在这里猜对了,您必须解锁用户的钥匙串! Juste run this : Juste运行此命令:

security unlock-keychain -p 'USER_PASSWORD' 'PATH_TO_USER_KEYCHAIN' 安全性解锁钥匙串-p'USER_PASSWORD''PATH_TO_USER_KEYCHAIN'

And that's it. 就是这样。

NB: Please let me know if I understood something wrong about all this. NB:请让我知道我是否理解所有这些错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM