Skip to content

Instantly share code, notes, and snippets.

@luhui
Created December 10, 2014 15:42
Show Gist options
  • Select an option

  • Save luhui/7a59a059b4f44bcab16c to your computer and use it in GitHub Desktop.

Select an option

Save luhui/7a59a059b4f44bcab16c to your computer and use it in GitHub Desktop.
#!/bin/bash
#使用Mogenerator工具在编译时自动生成/更新对应的core data对象
#see: http://rentzsch.github.io/mogenerator/
#注意!这个脚本不能直接在xcode的run script里调用。需要将脚本直接写在runscript里,否则会提示权限不足.so, please copy the code
# - 替换相应的路径和xxxxx.xcdatamodeld名称
MODELS_DIR="${PROJECT_DIR}/$PROJECT_NAME/Model/CoreData"
DATA_MODEL_PACKAGE="$MODELS_DIR/${ProjectName}.xcdatamodeld/${ProjectName}.xcdatamodel"
if [ -x /usr/local/bin/mogenerator ]; then
echo "mogenerator exists in /usr/local/bin path";
MOGENERATOR_DIR="/usr/local/bin";
elif [ -x /usr/bin/mogenerator ]; then
echo "mogenerator exists in /usr/bin path";
MOGENERATOR_DIR="/usr/bin";
else
echo "mogenerator not found"; exit 1;
fi
$MOGENERATOR_DIR/mogenerator --v2 --template-var arc=true -m "$DATA_MODEL_PACKAGE" -M "$MODELS_DIR/Machine/" -H "$MODELS_DIR/Human/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment