LoginSignup
2
1

More than 5 years have passed since last update.

react-native-google-signin で GoogleService-Info.plist を環境ごとに切り替える

Last updated at Posted at 2019-03-02

react-native-google-signin で、環境ごとに GoogleService-Info.plist を切り替えたい。

無理やりだが、下記で実現した。これしかないみたい。

  • GoogleService-Info.plist を .gitignore に追加
  • echo > ios/GoogleService-Info.plist などとして、空の GoogleService-Info.plist を作成する
  • open ios して、 GoogleService-Info.plist を Xcode に追加
  • Xcode にて、下記の Build Phase を一番上に設定する
# @see:
# - https://github.com/react-native-community/react-native-google-signin/pull/576
# - https://stackoverflow.com/questions/37615405/use-different-googleservice-info-plist-for-different-build-schemes/48789232#48789232

set -eux

DEV_GOOGLE_PLIST="${PROJECT_DIR}/GoogleService-Info-Dev.plist"
PROD_GOOGLE_PLIST="${PROJECT_DIR}/GoogleService-Info-Prod.plist"
GOOGLE_PLIST_PATH="${PROJECT_DIR}/GoogleService-Info.plist"
ERROR_MESSAGE="ERROR: ${CONFIGURATION} should be either 'Debug' or 'Production' in Build Phase 'Copy Google plist'"

case "${CONFIGURATION}" in
  'Debug') cp -r $DEV_GOOGLE_PLIST $GOOGLE_PLIST_PATH ;;
  'Production') cp -r $PROD_GOOGLE_PLIST $GOOGLE_PLIST_PATH ;;
  *) echo $ERROR_MESSAGE; exit 1;;
esac

個人的には、下記のプルリクがマージされてほしかった。

https://github.com/react-native-community/react-native-google-signin/pull/576

2
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
2
1