无法远程构建Xcode项目

时间:2018-10-11 08:53:28

标签: ios xcode shell unity3d ssh

我有一台jenkins服务器通过ssh连接到远程Mac mini,以执行必须从统一项目构建IPA的shell脚本。

在Mac mini上本地执行shell脚本时,一切正常。但是,当从jenkins(具有完全相同的参数和相同的用户)运行shell脚本时,它将无法对存档进行代码签名。

我将与您分享混淆的Shell脚本以及构建日志。

谢谢您的帮助。

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

因此,当从Mac mini的终端本地运行shell脚本时,一切都像灵符(甚至可以将构建版本安装在设备上)一样。

当要通过ssh远程运行shell脚本时,无法对归档文件进行代码签名。通过ssh使用的用户与本地运行脚本的用户相同。

这是错误:

  

CodeSign   /#######/Library/Developer/Xcode/DerivedData/Unity-iPhone-#########/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/### ######。app   (目标:Unity-iPhone)cd / ######### / xcodeProjPath导出   CODESIGN_ALLOCATE = /应用程序/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate

     

签名身份:“ #########”供应配置文件:“ iOS团队   供应配置文件:#########“                         (#########)

     

/ usr / bin / codesign --force --sign #########-授权   /########/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/InstallationBuildProducts位置/应用程序/# ########。app:   errSecInternalComponent

     

命令CodeSign失败,退出代码非零

     

**归档失败**

我现在有点卡住,因为我的所有尝试都根本不起作用... 预先感谢您的帮助。

编辑:

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

xcode版本10.0(10A255)

1 个答案:

答案 0 :(得分:-1)

好吧,对于所有在这个棘手的主题上苦苦挣扎的人(如果我们对macOS的了解不足,这是完全看不见的),仍然存在某种安全系统,可以在本地用户和远程访问用户之间发挥作用

因此,远程用户无法使用开箱即用的用于处理您的密钥和证书的密钥链(由codesign用来对您的构建进行签名)。首先需要解锁!!!

要了解系统上可用的钥匙串,只需在终端上键入:

  

安全列表钥匙串

您应该看到类似:

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

您猜到了,您必须解锁用户的钥匙串! Juste运行这个:

  

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

就是这样。

N.B: 如果我对所有这些都不了解,请告诉我。