APNs証明書を簡単に更新する方法

はじめに

1年に一回必ずやってくるAPNs証明書の更新。
非常に面倒でたまにしかやらないので、いつも忘れるのですが、これをコマンド一発でやってくれる便利なツールを紹介します。

Fastlane

https://docs.fastlane.tools/actions/pem/

iOS、Androidアプリで簡単にdeployments、releasesファイルを作成してくれるやつです。
これにAPNs証明書の更新をコマンド一発でやってくれるツールが入っています。

まずは、fastlaneをインストール
https://docs.fastlane.tools/
$ gem install fastlane

iOSプロジェクトのカレントディレクトリに移動して以下を実行
$ fastlane init
Gemfileとlockファイルが作成されます。

Fastfileを作成するとAppStoreへのアップ、TestFlightへのアップなどコマンドでできるようになりますが、その話はまた今度。

APNs証明書の更新

以下コマンドを実行
$ fastlane pem
[✔] 🚀 
[18:53:21]: fastlane detected a Gemfile in the current directory
[18:53:21]: however it seems like you don't use `bundle exec`
[18:53:21]: to launch fastlane faster, please use
[18:53:21]: 
[18:53:21]: $ bundle exec fastlane pem
[18:53:21]: 
[18:53:21]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile

+-------------------+------------------------+
|          Summary for PEM 2.101.1           |
+-------------------+------------------------+
| development       | false                  |
| generate_p12      | true                   |
| active_days_limit | 30                     |
| force             | false                  |
| save_private_key  | true                   |
| username          | hoge@funseek.co.jp |
| team_id           | 6X62PMQJAR             |
| output_path       | .                      |
+-------------------+------------------------+

[18:53:21]: Starting login with user 'hoge@funseek.co.jp'
[18:53:25]: Successfully logged in
[18:53:25]: To not be asked about this value, you can specify it using 'app_identifier'
[18:53:25]: The bundle identifier of your app: jp.co.funseek.Hoge
[18:53:40]: Existing push notification profile for 'jp.co.funseek.Hoge' is valid for 29 more days.
[18:53:40]: Creating a new push certificate for app 'jp.co.funseek.Hoge'.
[18:53:43]: Private key: /Users/yamazaki/src/swift/necosta/production_jp.co.funseek.Hoge.pkey
[18:53:43]: p12 certificate: /Users/yamazaki/src/swift/necosta/production_jp.co.funseek.Hoge.p12
[18:53:43]: PEM: /Users/yamazaki/src/swift/necosta/production_jp.co.funseek.Hoge.pem
途中で bundle identifierを聞かれるの入力

Private Key、p12、pemの3種類のファイルが作成されます。便利!!

コメント

このブログの人気の投稿

FunBizのシステム環境

EBに置いたrailsからAmazon Kinesis Data FirehoseでlogをamazonESに投げる

メッセージUIライブラリMessageKitの紹介