0
1

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 3 years have passed since last update.

Xcodeが保存したプロビジョニングプロファイルを削除する

Posted at

JenkinsやfastlaneなどのCIツールを使っていると段々と不要になった期限切れのプロビジョニングプロファイルがXcodeの作業ディレクトリに溜まってきて、そのうちに手動で削除するのも面倒になりついにはゴミだらけに。
そんな期限切れのプロビジョニングプロファイルを綺麗さっぱり掃除するためのシェルスクリプトを用意してみました。

# !/bin/bash

USER_NAME=`whoami`
TODAY=`date '+%s'`

# Remove old mobileprovision
MOBILEPROVISION_FILES=`find /Users/${USER_NAME}/Library/MobileDevice/Provisioning\ Profiles/ -maxdepth 1 -type f | sed 's!^.*/!!'`
for MOBILEPROVISION_FILE in ${MOBILEPROVISION_FILES}; do
  #echo ${MOBILEPROVISION_FILE}
  expire_date=`/usr/libexec/PlistBuddy -c "Print DeveloperCertificates:0" /dev/stdin <<< $(security cms -D -i "/Users/${USER_NAME}/Library/MobileDevice/Provisioning Profiles/${MOBILEPROVISION_FILE}") | openssl x509 -inform der -enddate -noout | sed -e 's/^notAfter=//g'`
  #echo $expire_date
  expire=`LANG=C date -j -f "%b %d %H:%M:%S %Y %Z" "$expire_date" '+%s'`
  if [ $TODAY -gt $expire ]; then
    echo ${MOBILEPROVISION_FILE} is expire on $expire_date removed.
    rm -f "/Users/${USER_NAME}/Library/MobileDevice/Provisioning Profiles/${MOBILEPROVISION_FILE}"
  fi
done
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?