Skip to content

Instantly share code, notes, and snippets.

@kristopherjohnson
Last active November 20, 2015 11:18
Show Gist options
  • Select an option

  • Save kristopherjohnson/5cd70b4eaf68da2b1992 to your computer and use it in GitHub Desktop.

Select an option

Save kristopherjohnson/5cd70b4eaf68da2b1992 to your computer and use it in GitHub Desktop.
Xcode build-phase script that generates source files if they are not present or if input file is newer
src="$SRCROOT/myproject/input.json"
dst_hpp="$SRCROOT/myproject/output.hpp"
dst_cpp="$SRCROOT/myproject/output.cpp"
if [ "$src" -nt "$dst_hpp" ] || [ "$src" -nt "$dst_cpp" ]; then
echo "Generating $dst_hpp and $dst_cpp..."
"$BUILT_PRODUCTS_DIR/codegenerator" "$src" "$dst_hpp" "$dst_cpp"
else
echo "$dst_hpp and $dst_cpp are up to date."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment