有时候我们需要获取Provisioning Profile的UUID,一般情况下我们是双击mobileprovision文件安装,在老版本Xcode的Organizer窗口里找到对应的UUID,新版本Xcode里不知道为什么这个路径下就找不到uuid了,幸运地我找到了另外一个软件:iPhone配置实用工具,这个软件里也能查看。
只是每次都要借助于GUI工具来查看还是太麻烦了,更好的方法是用命令行,我找到了这个:0xc010d/mobileprovision-read
使用方法:
在Terminal下输入下面的命令并回车:
curl https://raw.githubusercontent.com/0xc010d/mobileprovision-read/master/main.m | clang -framework Foundation -framework Security -o /usr/local/bin/mobileprovision-read -x objective-c -
这条命令的作用是下载mobileprovision-read的源码,然后编译,最后把生成的二进制文件mobileprovision-read
放入到/usr/local/bin/
路径下。
现在你就可以执行mobileprovision-read
命令来查看帮助了。
mobileprovision-read -- mobileprovision files querying tool. USAGE mobileprovision-read -f fileName [-o option] OPTIONS type – prints mobileprovision profile type (debug, ad-hoc, enterprise, appstore) appid – prints application identifier Will print raw provision‘s plist if option is not specified. You can also use key path as an option. EXAMPLES mobileprovision-read -f test.mobileprovision -o type Prints profile type mobileprovision-read -f test.mobileprovision -o UUID Prints profile UUID mobileprovision-read -f test.mobileprovision -o ProvisionedDevices Prints provisioned devices UDIDs mobileprovision-read -f test.mobileprovision -o Entitlements.get-task-allow Prints 0 if profile doesn‘t allow debugging 1 otherwise
查看UUID的命令是:
mobileprovision-read -f the-file-path -o UUID
测试可用。
之前也找了一些其它的方法来获取UUID,并写了下面的shell脚本:
#!/bin/bash if [ $# -ne 1 ] then echo "Usage: getmobileuuid the-mobileprovision-file-path" exit 1 fi mobileprovision_uuid=`grep UUID -A1 -a $1 | grep -o "[-A-Z0-9]\{36\}"` echo "UUID:"${mobileprovision_uuid}
但是不知道结果为什么为空
更新:
根据这个(http://stackoverflow.com/a/10775025)答案下面的评论,找到了另外一种方法,是使用了苹果的security
和PlistBuddy
工具,脚本如下:
#!/bin/bash if [ $# -ne 1 ] then echo "Usage: getmobileuuid the-mobileprovision-file-path" exit 1 fi # mobileprovision_uuid=`grep UUID -A1 -a $1 | grep -o "[-A-Z0-9]\{36\}"` mobileprovision_uuid=`/usr/libexec/PlistBuddy -c "Print UUID" /dev/stdin <<< $(/usr/bin/security cms -D -i $1)` echo "UUID is:" echo ${mobileprovision_uuid}
测试可行。
参考:
.mobileprovision files structure and reading - iDev blog
A command line tool to parse .mobileprovision file
verb-ios/install-provisioning-profile.sh at master · JonathanPorta/verb-ios
ios - Can an Xcode .mobileprovision file be ‘installed‘ from the command line? - Stack Overflow