Last active
September 2, 2015 19:13
-
-
Save casademora/f115102b2e6530e2554c to your computer and use it in GitHub Desktop.
Rebuild Core Data Entities Script
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/sh | |
## $1 is the path to the model relative to the project dir | |
## $2 is the name of the model file | |
##TODO, make the path optional and the model file required | |
mogen=`which mogenerator` | |
PlistBuddy=`which PlistBuddy` | |
if [[ -x $1 ]]; then | |
ENTITIES_DIR=$1 | |
else | |
ENTITIES_DIR=Library/Models | |
fi | |
HUMAN_FILES_OUTPUT_FOLDER=$PROJECT_DIR/$ENTITIES_DIR/entities | |
MACHINE_FILES_OUTPUT_FOLDER=$PROJECT_DIR/$ENTITIES_DIR/generated | |
MODEL_DATA_FOLDER=$PROJECT_DIR/$ENTITIES_DIR/$2 | |
echo "Rebuilding Core Data Entities" | |
#figure out current model version | |
if [[ -x "$MODEL_DATA_FOLDER/.xccurrentversion" ]]; then | |
CURRENT_MODEL_VERSION=`"$PlistBuddy" -c 'Print _XCCurrentVersionName' "$MODEL_DATA_FOLDER/.xccurrentversion"` | |
fi | |
if [[ -x $mogen ]]; then | |
if [[ -x $CURRENT_MODEL_VERSION ]];then | |
echo "Updating data objects from $MODEL_DATA_FOLDER/$CURRENT_MODEL_VERSION using $mogen" | |
else | |
echo "Updating data objects from $MODEL_DATA_FOLDER using $mogen" | |
fi | |
"$mogen" -m "$MODEL_DATA_FOLDER" -M "$MACHINE_FILES_OUTPUT_FOLDER" -H "$HUMAN_FILES_OUTPUT_FOLDER" --template-var arc=true --template-var overrideBaseClass=true --swift | |
else | |
echo "Mogenerator command not found" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment