52
52

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ipaファイルのProvisioningを差し替える

Posted at
プロビジョニングを入れ替える
#!/bin/bash

#元のipaファイル
IPA_FILE=test.ipa

#出力するipaファイル
DEST_FILE=test_copy.ipa

#差し替えるProvisioning Profile
PROV_FILE=test.mobileprovision

#差し替えるEntitlements
ENTITLEMENTS=Entitlements.plist

#差し替える署名の証明書の名前
SIGN="iPhone Developer: DEVELOPER NAME (XXXXXXXXXX)"

mkdir -p tmp
cp ${IPA_FILE} tmp
cd tmp
unzip -q ${IPA_FILE}
APP_FILE=Payload/`ls Payload`

#署名を削除
rm -r ${APP_FILE}/_CodeSignature

#プロビジョニングファイルを新しいものに置き換え
cp ../${PROV_FILE} ${APP_FILE}/embedded.mobileprovision

#.appに署名し直す
codesign --force --sign "${SIGN}"\
	--resource-rules ${APP_FILE}'/ResourceRules.plist' ${APP_FILE}

# #.appを署名し直す(entitlementsも書き換える)
# codesign --force --sign "${SIGN}"\
# 	--resource-rules ${APP_FILE}'/ResourceRules.plist'\
# 	--entitlements ../${ENTITLEMENTS} ${APP_FILE}

#署名が上手くいったか確認
codesign -d --entitlements - ${APP_FILE}

# #再パッケージ(使う時は、次のzip圧縮はいらない。失敗するかも・・・)
# /usr/bin/xcrun -sdk iphoneos PackageApplication\
# 	-v ${APP_FILE} -o ${DEST_FILE} --sign "${SIGN}" --embed ../${PROV_FILE}

#zip圧縮で新しいipaファイル作成
zip -qr ${DEST_FILE} Payload
cp -f ${DEST_FILE} ../
cd ../
rm -rf tmp
キーチェーンに登録された証明書の一覧を出力する
security find-identity -p codesigning -v
Entitlements.plistサンプル
<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 
<plist version="1.0"> 
    <dict> 
        <key>application-identifier</key> 
        <string>XXXXXXXXXX.*</string> 
        <key>keychain-access-groups</key> 
        <array> 
            <string>XXXXXXXXXX.*</string> 
        </array> 
        <key>get-task-allow</key> 
        <true/> 
    </dict> 
</plist> 

###参考

iOSアプリの署名を付け替える - Qiita [キータ]
http://qiita.com/beakmark/items/33c0b73603e491f08a33

iOS アプリのprovisioning profile差し替え方法 | Septeni Engineers' Blog | セプテーニ エンジニアブログ
http://labs.septeni.co.jp/?p=815

doesNotRecognizeBlog, codesign(1) についてのメモ
http://mtakagi.tumblr.com/cli/codesign.1/

52
52
0

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
52
52

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?