diff --git a/scripts/pod-install.sh b/scripts/pod-install.sh index 77237bb207b4..5d529098dad1 100755 --- a/scripts/pod-install.sh +++ b/scripts/pod-install.sh @@ -19,28 +19,28 @@ cd "$ROOT_DIR" || exit 1 # Cleanup and exit # param - status code function cleanupAndExit { - cd "$START_DIR" || exit 1 - exit "$1" + cd "$START_DIR" || exit 1 + exit "$1" } source scripts/shellUtils.sh # Check if bundle is installed if ! bundle --version > /dev/null 2>&1; then - error 'bundle is not installed. Please install bundle and try again' - cleanupAndExit 1 + error 'bundle is not installed. Please install bundle and try again' + cleanupAndExit 1 fi # Check if jq is installed if ! jq --version > /dev/null 2>&1; then - error 'jq is not installed. Please install jq and try again' - cleanupAndExit 1 + error 'jq is not installed. Please install jq and try again' + cleanupAndExit 1 fi # Check if yq is installed if ! yq --version > /dev/null 2>&1; then - error 'yq is not installed. Please install yq and try again' - cleanupAndExit 1 + error 'yq is not installed. Please install yq and try again' + cleanupAndExit 1 fi # See if we're in the HybridApp repo @@ -60,46 +60,53 @@ fi echo -e "${BLUE}Executing npm run pod-install for standalone NewDot...${NC}" -CACHED_PODSPEC_DIR='ios/Pods/Local Podspecs' +CACHED_PODSPEC_DIR=''; +if [[ "$IS_HYBRID_APP_REPO" == "true" ]]; then + CACHED_PODSPEC_DIR='Mobile-Expensify/ios/Pods/Local Podspecs' +else + CACHED_PODSPEC_DIR='ios/Pods/Local Podspecs' +fi +readonly CACHED_PODSPEC_DIR + if [ -d "$CACHED_PODSPEC_DIR" ]; then - info "Verifying pods from Podfile.lock match local podspecs..." + info "Verifying pods from Podfile.lock match local podspecs..." - # Convert podfile.lock to json since yq is missing some features of jq (namely, if/else) - PODFILE_LOCK_AS_JSON="$(yq -o=json ios/Podfile.lock)" + # Convert podfile.lock to json since yq is missing some features of jq (namely, if/else) + PODFILE_LOCK_AS_JSON="$(yq -o=json ios/Podfile.lock)" - # Retrieve a list of pods and their versions from Podfile.lock - declare PODS_FROM_LOCKFILE - if ! read_lines_into_array PODS_FROM_LOCKFILE < <(jq -r '.PODS | map (if (.|type) == "object" then keys[0] else . end) | .[]' < <(echo "$PODFILE_LOCK_AS_JSON")); then - error "Error: Could not parse pod versions from Podfile.lock" - cleanupAndExit 1 - fi - - for CACHED_PODSPEC_PATH in "$CACHED_PODSPEC_DIR"/*; do - if [ -f "$CACHED_PODSPEC_PATH" ]; then - # The next two lines use bash parameter expansion to get just the pod name from the path - # i.e: `ios/Pods/Local Podspecs/hermes-engine.podspec.json` to just `hermes-engine` - # It extracts the part of the string between the last `/` and the first `.` - CACHED_POD_NAME="${CACHED_PODSPEC_PATH##*/}" - CACHED_POD_NAME="${CACHED_POD_NAME%%.*}" - - info "🫛 Verifying local pod $CACHED_POD_NAME" - CACHED_POD_VERSION="$(jq -r '.version' < <(cat "$CACHED_PODSPEC_PATH"))" - for POD_FROM_LOCKFILE in "${PODS_FROM_LOCKFILE[@]}"; do - # Extract the pod name and version that was parsed from the lockfile. POD_FROM_LOCKFILE looks like `PodName (version)` - IFS=' ' read -r POD_NAME_FROM_LOCKFILE POD_VERSION_FROM_LOCKFILE <<< "$POD_FROM_LOCKFILE" - if [[ "$CACHED_POD_NAME" == "$POD_NAME_FROM_LOCKFILE" ]]; then - if [[ "$POD_VERSION_FROM_LOCKFILE" != "($CACHED_POD_VERSION)" ]]; then + # Retrieve a list of pods and their versions from Podfile.lock + declare PODS_FROM_LOCKFILE + if ! read_lines_into_array PODS_FROM_LOCKFILE < <(jq -r '.PODS | map (if (.|type) == "object" then keys[0] else . end) | .[]' < <(echo "$PODFILE_LOCK_AS_JSON")); then + error "Error: Could not parse pod versions from Podfile.lock" + cleanupAndExit 1 + fi + + for CACHED_PODSPEC_PATH in "$CACHED_PODSPEC_DIR"/*; do + if [ -f "$CACHED_PODSPEC_PATH" ]; then + # The next two lines use bash parameter expansion to get just the pod name from the path + # i.e: `ios/Pods/Local Podspecs/hermes-engine.podspec.json` to just `hermes-engine` + # It extracts the part of the string between the last `/` and the first `.` + CACHED_POD_NAME="${CACHED_PODSPEC_PATH##*/}" + CACHED_POD_NAME="${CACHED_POD_NAME%%.*}" + + info "🫛 Verifying local pod $CACHED_POD_NAME" + CACHED_POD_VERSION="$(jq -r '.version' < <(cat "$CACHED_PODSPEC_PATH"))" + for POD_FROM_LOCKFILE in "${PODS_FROM_LOCKFILE[@]}"; do + # Extract the pod name and version that was parsed from the lockfile. POD_FROM_LOCKFILE looks like `PodName (version)` + IFS=' ' read -r POD_NAME_FROM_LOCKFILE POD_VERSION_FROM_LOCKFILE <<< "$POD_FROM_LOCKFILE" + if [[ "$CACHED_POD_NAME" == "$POD_NAME_FROM_LOCKFILE" ]]; then + if [[ "$POD_VERSION_FROM_LOCKFILE" != "($CACHED_POD_VERSION)" ]]; then + clear_last_line + info "⚠️ found mismatched pod: $CACHED_POD_NAME, removing local podspec $CACHED_PODSPEC_PATH" + rm "$CACHED_PODSPEC_PATH" + echo -e "\n" + fi + break + fi + done clear_last_line - info "⚠️ found mismatched pod: $CACHED_POD_NAME, removing local podspec $CACHED_PODSPEC_PATH" - rm "$CACHED_PODSPEC_PATH" - echo -e "\n" - fi - break fi - done - clear_last_line - fi - done + done fi cd ios || cleanupAndExit 1