diff --git a/xcode/aux_scripts/install_env.sh b/xcode/aux_scripts/install_env.sh index d1c1fc0..379c640 100644 --- a/xcode/aux_scripts/install_env.sh +++ b/xcode/aux_scripts/install_env.sh @@ -1,3 +1,5 @@ +#!/bin/sh + # Description: # Add user defined enviroment if programm not found # @@ -14,7 +16,19 @@ function source_home_file { file="$HOME/$1" - [[ -f "${file}" ]] && source "${file}" + + if [[ -f "${file}" ]]; then + if ! source "${file}"; then + export_commands="$(cat "${file}" | grep "^export PATH=")" + + while read export_command + do + eval "$export_command" + done <<< "$export_commands" + fi + fi + + return 1 } # Use specific exec due to Xcode has custom value of $PATH diff --git a/xcode/build_phases/localization.sh b/xcode/build_phases/localization.sh index dea12e3..1b3d6e8 100644 --- a/xcode/build_phases/localization.sh +++ b/xcode/build_phases/localization.sh @@ -19,18 +19,29 @@ # . localization.sh common/strings Resources/Localization/ .main # +readonly EXIT_SUCCESS=0 +readonly EXIT_FAILURE=1 + +. ${SCRIPT_DIR}/../aux_scripts/install_env.sh php + STRINGS_FOLDER=${1:-"common/strings"} LOCALIZATION_PATH=${2:-"${PRODUCT_NAME}/Resources/Localization/"} BUNDLE=${3:-".main"} if ! [ -e ${LOCALIZATION_PATH} ]; then echo "${LOCALIZATION_PATH} path does not exist. Add these folders and try again." - exit 1 + exit ${EXIT_FAILURE} fi if ! [ -e "${STRINGS_FOLDER}" ]; then echo "${STRINGS_FOLDER} path does not exist. Submodule with strings should be named common and contain strings folder." - exit 1 + exit ${EXIT_FAILURE} fi -php ${SCRIPT_DIR}/../aux_scripts/import_strings.php ${LOCALIZATION_PATH} ${STRINGS_FOLDER} ${BUNDLE} +if which php >/dev/null; then + php ${SCRIPT_DIR}/../aux_scripts/import_strings.php ${LOCALIZATION_PATH} ${STRINGS_FOLDER} ${BUNDLE} +else + echo "warning: php not installed, install using 'brew install php'" + + exit ${EXIT_FAILURE} +fi \ No newline at end of file