LoginSignup
6

More than 5 years have passed since last update.

ipaのembedded.mobileprovisionの中身を一発で表示する

Last updated at Posted at 2016-10-25

ipaをExportした後、実機にインストールが失敗することがあり、embedded.mobileprovisionファイルをデバッグすることがあります。
特にAdHoc配布の場合、デバイスが正しく登録されたかどうかはこのファイルを見るとわかります。まあ、Provisioning Profile自体がDeveloperポータル上で無効になっていたら意味ないのですが。

毎回unzipして。。とするのも面倒なので、シェルにしてみました。

Update: 2017/05/18

goのコマンドにしてhomebrewでインストールできるようにしました。
https://github.com/toshi0383/ipanema

$ brew tap toshi0383/ipanema && brew install ipanema
$ ipanema -E Sample.ipa
.
.
.
    <key>ProvisionedDevices</key>
    <array>
        <string>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</string>
        <string>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</string>
        <string>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</string>
    </array>

inspect_ipa_mobileprovision.sh

inspect_ipa_mobileprovision.sh
# name:
#   inspect_ipa_mobileprovision.sh 
#
# description:
#   Extract ipa file and decode all embedded.mobileprovision file inside.
#
# author:
#   Toshihiro Suzuki (@toshi0383)
#
# license:
#   MIT
#
# parameters:
#   - 1 IPA_PATH: path to ipa
#

#!/bin/bash
IPA_PATH=${1:?ipa path is missing}
if [ ! -f "$IPA_PATH" ];then
    echo "No such file ${IPA_PATH}"
    exit 1
fi
tmp=`mktemp`
tmppayload=`mktemp -d`

cmsdecrypt='security cms -D -i'

unzip "${IPA_PATH}" Payload/**/*mobileprovision -d $tmppayload > /dev/null

find $tmppayload -name "*mobileprovision" > $tmp

while read line;
do
    $cmsdecrypt $line 2> /dev/null
done < $tmp
rm $tmp
rm -rf $tmppayload

使い方

パスを通してどこでも使えるようにすると良いかな、と。コマンドにしちゃってもいいのかもしれませんが。

$ inspect_ipa_mobileprovision.sh path/to/your.ipa | head
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>AppIDName</key>
    <string>XC your app id</string>
    <key>ApplicationIdentifierPrefix</key>
    <array>
    <string>XXXXXXXXXX</string>
    </array>

plist形式で出力されますが、個別のファイルで出力できるようにすると、その後plutilなりPlistBuddyなりで料理しやすいのかもしれませんね。今はApp Extensionの分など複数見つかってもまとめて出力してしまっています。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6