27

我正在设置 Jenkins 以自动化 iOS 构建。是否有可能将未添加到 Xcode 中的配置工具中的 .mobileprovision 文件提供给 xcodebuild?

我知道我可以使用 PROVISIONING_PROFILE 和 PROVISIONING_PROFILE[sdk=iphoneos*] 但它们需要将配置文件添加到管理器中。

我知道我可以用 xcrun 进行操作。但在运行 xcrun 之前,我必须使用 xcodebuild 成功签署应用程序。

有什么方法可以将配置文件(.mobileprovision)提供给xcodebuild?

4

2 回答 2

48

我们对此有一个解决方案 - 本质上,您需要做的是通过将 .mobileprovision 文件复制到以移动配置文件的 UUID 命名的目录来“安装”它。这就是双击 .mobileprovision 文件时 Xcode Organizer 实际执行的操作。

有一个名为 mpParse 的小程序可以从脚本使用的 mobileprovision 文件中提取 UUID - 代码中的下载链接。然后将 mobileprovision 文件复制到正确的位置非常简单。

这是我为此制作的一个 shell 脚本:

#!/bin/sh

# 2012 - Ben Clayton (benvium). Calvium Ltd
# Found at https://gist.github.com/2568707
#
# This script installs a .mobileprovision file without using Xcode. Unlike Xcode, it'll 
# work over SSH.
#
# Requires Mac OS X (I'm using 10.7 and Xcode 4.3.2)
#
# IMPORTANT NOTE: You need to download and install the mpParse executable from     http://idevblog.info/mobileprovision-files-structure-and-reading
# and place it in the same folder as this script for this to work.
#
# Usage installMobileProvisionFile.sh path/to/foobar.mobileprovision

if [ ! $# == 1 ]; then
 echo "Usage: $0 (path/to/mobileprovision)"
 exit
fi

mp=$1

uuid=`/usr/libexec/PlistBuddy -c 'Print UUID' /dev/stdin <<< $(security cms -D -i ${mp})`

echo "Found UUID $uuid"

output="~/Library/MobileDevice/Provisioning Profiles/$uuid.mobileprovision"

echo "copying to $output.."
cp "${mp}" "$output"

echo "done"

您可以直接从https://gist.github.com/2568707下载脚本

运行脚本后,您可以在 xcodebuild 中使用 PROVISIONING_PROFILE 和 PROVISIONING_PROFILE[sdk=iphoneos*] 来创建您的应用程序。我们在生产中使用它。

编辑:仅供参考,我不久前在这里基本上问了这个问题(可以从命令行“安装”一个 Xcode .mobileprovision 文件吗?)并在似乎没有人知道的情况下提出了上述问题:-)

更新: 作为 mpParse 的替代方案,可以使用苹果工具: /usr/libexec/PlistBuddy -c 'Print UUID' /dev/stdin <<< $(security cms -D -i path_to_mobileprovision)

于 2012-06-23T07:57:01.923 回答
0

如果你使用 fastlane 的 sigh ,你可以将它的输出分配给一个变量 provision_id=sigh

如果 sigh 有参数,这也有效:sigh(...)

这是唯一对我有用的脚本:

`var=$(grep UUID -A1 -a | grep -io "[-A-Z0-9]{36}")'

与: "$var.mobileprovision"

于 2017-03-02T09:58:56.203 回答