Last active
December 13, 2020 01:21
-
-
Save Ashton-W/a47ec8b128ecbe470632 to your computer and use it in GitHub Desktop.
CopyConfigurationResources Xcode Build Phase Script
This file contains 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
#!/usr/bin/env bash | |
# Build Phase Script for use in Xcode | |
# Copy Resources based on Configuration | |
# | |
# https://gist.github.com/Ashton-W/a47ec8b128ecbe470632 | |
set -o nounset | |
# From Build Environment | |
CONFIGURATION="${CONFIGURATION}" | |
SOURCE_ROOT="${SOURCE_ROOT}" | |
CODESIGNING_FOLDER_PATH="${CODESIGNING_FOLDER_PATH}" | |
RESOURCES_PATH="${RESOURCES_PATH:-$SOURCE_ROOT/$TARGET_NAME/Resources}" | |
# | |
copy_common_resources() { | |
cp -vRf "$RESOURCES_PATH/" "$CODESIGNING_FOLDER_PATH/" | |
} | |
# | |
copy_config_resources() { | |
local config_path="$RESOURCES_PATH-$CONFIGURATION/" | |
if [ -d "$config_path" ]; then | |
cp -vRf "$config_path" "$CODESIGNING_FOLDER_PATH/" | |
fi | |
} | |
copy_common_resources && copy_config_resources | |
This file contains 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
#!/usr/bin/env bash | |
# Test for https://gist.github.com/Ashton-W/a47ec8b128ecbe470632 | |
setUp() { | |
mkdir -p ./Test/Resources | |
mkdir -p ./Test/Resources-Debug | |
mkdir -p ./Test/Resources-Release | |
mkdir -p ./Test/Results | |
touch ./Test/Resources/common | |
touch ./Test/Resources-Debug/debug | |
touch ./Test/Resources-Release/release | |
} | |
tearDown() { | |
rm -rf ./Test/Results | |
} | |
test1() { | |
export CONFIGURATION="Debug" | |
export SOURCE_ROOT="./Test" | |
export CODESIGNING_FOLDER_PATH="./Test/Results" | |
printf "\n\n# Testing 'Debug' Configuration\n" | |
./CopyConfigurationResources.sh | |
printf "# Should see common and debug files\n" | |
tree "$CODESIGNING_FOLDER_PATH" | |
} | |
test2() { | |
export CONFIGURATION="Unknown" | |
export SOURCE_ROOT="./Test" | |
export CODESIGNING_FOLDER_PATH="./Test/Results" | |
printf "\n\n# Testing 'Unknown' Configuration\n" | |
./CopyConfigurationResources.sh | |
printf "# Should only see common files\n" | |
tree "$CODESIGNING_FOLDER_PATH" | |
} | |
main() { | |
setUp && test1 && tearDown | |
setUp && test2 && tearDown | |
} | |
main | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Intended to be used with a directory structure like: