Last active
July 11, 2023 12:57
-
-
Save k-thorat/40bbc062e797f7d4a5b63d1c0dc31621 to your computer and use it in GitHub Desktop.
Xcode - Run Script - Create Input & Output file list of git-changed files to optimise build process.
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
#!/bin/sh | |
# Read more at: | |
# https://stackedheaps.com/2023/07/02/optimise-xcode-builds-with-input-output-file-lists | |
# Script Arguments: | |
# $1 = xcfilelist name without extension. | |
# Example: ChangedFiles | |
# $2 = Optional Output directory | |
# Path relative to $SRCROOT for saving xcfilelist. | |
# By default, file will be saved in projects root directory | |
# ********************************************************************************** | |
# Create xcfilelist for the changed file. | |
XC_FILE_LIST_NAME=$1 | |
OUTPUT_DIRECTORY=$2 | |
if [ ! -z $OUTPUT_DIRECTORY ]; then | |
PROJECT_XC_FILE=$SRCROOT/$OUTPUT_DIRECTORY/$XC_FILE_LIST_NAME.xcfilelist | |
else | |
PROJECT_XC_FILE=$SRCROOT/$XC_FILE_LIST_NAME.xcfilelist | |
fi | |
BUILD_XC_FILE=$DERIVED_FILE_DIR/$XC_FILE_LIST_NAME.xcfilelist | |
OUTPUT_FILE=$DERIVED_FILE_DIR/$XC_FILE_LIST_NAME.txt | |
# Find files and add the contents to xcfilelist. | |
git --no-pager diff --name-only | sed -e 's#^#$(SRCROOT)/#;' > $BUILD_XC_FILE | |
# Compare SRCROOT file with DERIVED_FILE_DIR file. Copy if anything has changed. | |
cmp --silent $PROJECT_XC_FILE $BUILD_XC_FILE || cp -f $BUILD_XC_FILE $PROJECT_XC_FILE | |
# Create an output file | |
touch $OUTPUT_FILE | |
# ********************************************************************************** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment