我刚刚在我的开发机器上安装了mogenerator+xmo'd,并且想要开始使用它。我真正能在网上找到的唯一指令是来自a previous SO post的,这些指令在XCode 4上不起作用(或者至少⌘我不再提取元数据,我不知道怎么做)。
那么,为了启动和运行它,只需要在.xcdatamodeld的注释中添加xmod (无论它们在哪里),然后在保存时生成/更新类就行了吗?
发布于 2011-03-11 13:11:09
现在Xcode4已经发布了,让我们来看看mogenerator的Issues页面
发布于 2012-05-05 03:07:36
在我修改了我的模型文件之后,我只需要从终端手动运行mogenerator即可。使用Xcode4和ARC,可以做到这一点:
cd <directory of model file>
mogenerator --model <your model>.xcdatamodeld/<current version>.xcdatamodel --template-var arc=YES也许我会在某一时刻使用构建脚本,但是终端方法太简单了,不会搞砸。
发布于 2012-04-05 13:29:39
我发现“构建阶段”中的脚本比“构建规则”更可靠。
在目标的“构建阶段”下,选择底部的按钮“添加运行脚本”。将run脚本拖到顶部,以便它在编译源代码之前执行。
请记住,实际的数据模型文件(.xcdatamodel)包含在一个包(.xcdatamodeld)中,您只需要为您的项目编译最新的数据模型。
将以下内容添加到脚本中(根据需要替换尖括号中的文本)
MODELS_DIR="${PROJECT_DIR}/<path to your models without trailing slash>"
DATA_MODEL_PACKAGE="$MODELS_DIR/<your model name>.xcdatamodeld"
CURRENT_VERSION=`/usr/libexec/PlistBuddy "$DATA_MODEL_PACKAGE/.xccurrentversion" -c 'print _XCCurrentVersionName'`
# Mogenerator Location
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 --model "$DATA_MODEL_PACKAGE/$CURRENT_VERSION" --output-dir "$MODELS_DIR/"根据需要向mogenerator添加选项。--base-class <your base class>和--template-var arc=true很常见。
https://stackoverflow.com/questions/5118718
复制相似问题