Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save phuochau/77264f101ed1a3f83a49c560ea3eac16 to your computer and use it in GitHub Desktop.
Save phuochau/77264f101ed1a3f83a49c560ea3eac16 to your computer and use it in GitHub Desktop.
Bash script to read version in package.json and set it for Info.plist in React Native Project
#!/bin/bash
PROJECT_DIR="ios/Invygo"
INFOPLIST_FILE="Info.plist"
INFOPLIST_DIR="${PROJECT_DIR}/${INFOPLIST_FILE}"
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')
# Update plist with new values
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${PACKAGE_VERSION#*v}" "${INFOPLIST_DIR}"
git add "${INFOPLIST_DIR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment