-
-
Save EgzonArifi/755c1113da9975c366100ad6ba03257c to your computer and use it in GitHub Desktop.
Creates .env and .local.xcconfig files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Define environment variables (you can customize this list as needed) | |
ENV_VARS=("API_KEY" "SDK_LICENSE_KEY") | |
# Get the script's directory | |
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | |
# Check if a path is provided | |
TARGET_PATH="${script_dir}/../../YourProject/Configs/" | |
if [ -n "$1" ]; then | |
TARGET_PATH="${1%/}/" | |
fi | |
# Create environment-specific .env files | |
ENV_FILES=("dev" "stage" "prod") | |
for env_file in "${ENV_FILES[@]}"; do | |
file_name=".env.${env_file}" | |
touch "${TARGET_PATH}${file_name}" | |
echo "# Add your ${env_file} environment variables in this file" > "${TARGET_PATH}${file_name}" | |
for var in "${ENV_VARS[@]}"; do | |
echo "${var}=" >> "${TARGET_PATH}${file_name}" | |
done | |
echo "Created ${TARGET_PATH}${file_name} file. Please add your environment variables." | |
done | |
# Create .local.xcconfig files from .xcconfig files | |
CONFIG_FILES=("ConfigDev" "ConfigStage" "ConfigProd") | |
for config_file in "${CONFIG_FILES[@]}"; do | |
original_file="${config_file}.xcconfig" | |
local_file="${config_file}.local.xcconfig" | |
if [ -f "${TARGET_PATH}${original_file}" ]; then | |
cp "${TARGET_PATH}${original_file}" "${TARGET_PATH}${local_file}" | |
echo "Created ${TARGET_PATH}${local_file} from ${TARGET_PATH}${original_file}." | |
else | |
echo "Warning: Missing ${TARGET_PATH}${original_file}." | |
fi | |
done | |
echo "Setup completed. You can now build and run the project." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment