概要
CircleCIやTravisCIでiOSアプリを自動ビルドしていると .p12ファイル
が必要になることが良くあります。割りと簡単に.p12ファイル
を抜き出すことが出来たのでご紹介します。
手順
Bitrise製のツールを使います。
以下コマンドを打って、プロジェクトファイルをドラッグ&ドロップで渡すだけです。
$ bash -l -c "$(curl -sfL https://raw.githubusercontent.com/bitrise-tools/codesigndoc/master/_scripts/install_wrap.sh)"
本家サイトの説明はこちらです。
http://devcenter.bitrise.io/docs/provprofile-cert-export
The easiest way to get the required code signing files is to use our codesigndoc > tool.
Using it is as easy as opening your Terminal.app on your Mac and running: bash -> l -c "$(curl -sfL https://raw.githubusercontent.com/bitrise-tools/codesigndoc/master/_scripts/install_wrap.sh)". Then opening your Finder.app > and drag-and-drop the .xcodeproj or xcworkspace file into the command line in > your terminal.
やってみた
$ bash -l -c "$(curl -sfL https://raw.githubusercontent.com/bitrise-tools/codesigndoc/master/_scripts/install_wrap.sh)"
=> Creating a temporary directory for codesigndoc ...
=> Downloading version: 0.9.15
=> Downloading codesigndoc from (https://github.com/bitrise-tools/codesigndoc/releases/download/0.9.15/codesigndoc-Darwin-x86_64) to (/var/folders/_h/40x4tdm92zx5yk15pt8bnxn80000gp/T/codesigndoc.ULmOA12R/codesigndoc) ...
######################################################################## 100.0%
=> Making it executable ...
=> codesigndoc version: 0.9.15
=> Running codesigndoc scan ...
Please drag-and-drop your Xcode Project (.xcodeproj)
or Workspace (.xcworkspace) file, the one you usually open in Xcode,
then hit Enter.
(Note: if you have a Workspace file you should most likely use that) :
最初にプロジェクトファイルをドラッグ&ドロップするように言われるので、ドラッグ&ドロップしてEnterを押します。その後、何回か質問されますが特に難しいことはないので省きます。
INFO[16:51:51] Exporting the Identities (Certificates):
* Identity: iPhone Distribution: HOGEHOGE (XXXXXXXXXX)
INFO[16:51:51] Exporting from Keychain, using empty Passphrase ...
INFO[16:51:51] This means that if you want to import the file the passphrase at import should be left empty,
INFO[16:51:51] you don't have to type in anything, just leave the passphrase input empty.
INFO[16:51:51] You'll most likely see popups (one for each Identity) from Keychain,
INFO[16:51:51] you will have to accept (Allow) those to be able to export the Identities!
Exports finished you can find the exported files at: /Users/yukatou/codesigndoc_exports
Opened the directory in Finder.
That's all.
You just have to upload the found code signing files and you'll be good to go!
成功すると codesigndoc_exports
というディレクトリが作成されます。
ディレクトリ配下に.p12ファイルがあることが確認できます。
$ ls codesigndoc_exports/*.p12
codesigndoc_exports/Identities.p12
.p12ファイルのパスフレーズは空で設定されていますのでご注意を。