1#!/usr/bin/env bash
2
3set -eo pipefail
4
5DEST="$CONFIGURATION_BUILD_DIR"
6RESOURCE_BUNDLE_NAME="EXConstants.bundle"
7EXPO_CONSTANTS_PACKAGE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
8
9# For classic main project build phases integration, will be no-op to prevent duplicated app.config creation.
10#
11# `$PROJECT_DIR` is passed by Xcode as the directory to the xcodeproj file.
12# in classic main project setup it is something like /path/to/app/ios
13# in new style pod project setup it is something like /path/to/app/ios/Pods
14PROJECT_DIR_BASENAME=$(basename $PROJECT_DIR)
15if [ "x$PROJECT_DIR_BASENAME" != "xPods" ]; then
16  exit 0
17fi
18
19# If PROJECT_ROOT is not specified, fallback to use Xcode PROJECT_DIR
20PROJECT_ROOT=${PROJECT_ROOT:-"$PROJECT_DIR/../.."}
21PROJECT_ROOT=${PROJECT_ROOT:-"$EXPO_CONSTANTS_PACKAGE_DIR/../.."}
22
23cd "$PROJECT_ROOT" || exit
24
25"${EXPO_CONSTANTS_PACKAGE_DIR}/scripts/with-node.sh" "${EXPO_CONSTANTS_PACKAGE_DIR}/scripts/getAppConfig.js" "$PROJECT_ROOT" "$DEST/$RESOURCE_BUNDLE_NAME"
26