如何使用 Mogenerator?
我安装了 Mogenerator。现在我该怎么办?我该如何使用它?
我遇到的第一个问题是我不知道它安装在哪里。在安装过程中,它只让我选择要安装它的硬盘驱动器,而不是目录。最自然的位置是 Applications
文件夹,但它不在那里。
接下来,自述文件(我在网上找到的)指出:
Xmo'd 的工作原理是注意到您的 *.xcdatamodel 已保存。如果模型文件的Xcode项目项注释 包含 xmod,会触发 AppleScript 根据您的情况创建一个文件夹 模型的文件名并填充它 以及来自的派生源代码文件 你的模型。然后它添加新的 将文件夹作为一个组添加到您的项目中 引用并添加所有来源 文件添加到您的项目。
上述说法有几个问题不太清楚:
- “模型文件的Xcode项目项注释”指的是什么?我怎样才能让它包含“xmod”?
- 添加此注释并让 mogenerator 监视
.xcdatamodel
文件是使用 mogenerator 的唯一方法吗?有什么方法可以手动运行 mogenerator 以便它重新创建生成的文件?
I installed Mogenerator. Now what do I do? How do I use it?
The first problem I have is that I have no idea where it was installed to. During the install process, it only let me select the hard drive to install it on, not the directory. The most natural location would be the Applications
folder, but it isn't there.
Next, the readme (which I found online) states:
Xmo'd works by noticing when your
*.xcdatamodel is saved. If the model file's Xcode project item comment
contains xmod, an AppleScript is fired
that creates a folder based on your
model's file name and populates it
with derived source code files from
your model. It then adds the new
folder to your project as a Group
Reference and adds all the source
files to your project.
There are several issues with the above statement that aren't clear:
- What does "the model file's Xcode project item comment" refer to? How can I make it contain "xmod"?
- Is adding this comment and having mogenerator monitor the
.xcdatamodel
file the only way to use mogenerator? Is there any way I can manually run mogenerator so that it recreates the generated files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
需要注意的另一件事是:您必须已将实体的 Class 属性设置为与 NSManagedObject 不同的属性。否则 Xmo'd 将不会做任何事情。
注意:据我所知,Xmo'd 目前不适用于 Xcode 4/5。
我所做的只是在 Xcode 中添加一个“MOGenerator”目标:
现在您只需运行此目标即可更新 MOGenerator 生成的内容。
One more caveat to be aware of: You have to already set the Class properties of your entities to something different than NSManagedObject. Otherwise Xmo'd won't do anything.
Note: Xmo'd currently doesn't work with Xcode 4/5, afaik.
What I do is just add a "MOGenerator" target in Xcode:
Now you can update your MOGenerator-generated by simply running this target.
我记得 mogenerator 是一个安装到您的开发人员目录中的脚本。但是,它可能会安装到 ~/Library 下的 Xcode 脚本目录中。
手动触发应用程序是什么意思?您可以通过“触摸”数据模型来触发构建。 对数据模型的任何保存都将触发 Xcode 中的构建
如果您选择模型文件并点击 ⌘I,您将获得其元数据, 。单击评论选项卡并在其中添加 xmod。 mogenerator 会查找该注释以了解是否应该生成文件。
更新
您可以从命令行运行 mogenerator 并让它监视您的文件。在终端中输入
mogenerator --help
以查看选项。mogenerator is a script that is installed into your developer directory as I recall. However it might be installed into the Xcode scripts directory under your ~/Library.
What do you mean by manually triggering the application? You can trigger a build by "touching" the data model. Any save on the data model will trigger the build
In Xcode if you select the model file and hit ⌘I you will get its metadata. Click on the comments tab and add xmod there. mogenerator looks for that comment to know if it should generate files.
Update
You can run mogenerator from the command line as well as have it monitor your files. Type
mogenerator --help
in the Terminal to see the options.我搜索了我的硬盘并找到了以下文件:
该应用程序安装到:
/usr/bin/mogenerator
。/Library/Application Support/mogenerator/
目录包含一些.motemplate
文件。I searched my hard drive and found the following files:
The application is installed to:
/usr/bin/mogenerator
.The
/Library/Application Support/mogenerator/
directory contains some.motemplate
files.⌘我不再在 Xcode 4 中工作。请查看命令行工具。这是文档
⌘I doesn't work in Xcode 4 any more. please check out the command line tool. Here is the doc
研究
make_installer.command
的第 22 行< /a>,我发现/Developer/Library/Xcode/Plug-ins/Xmod.pbplugin
也安装了。然后,在 mogenerator GitHub Issues 中搜索“卸载”,我发现了官方 创建者本人提供的有关如何卸载 mogenerator 的说明。
Studying line 22 of
make_installer.command
, I found that/Developer/Library/Xcode/Plug-ins/Xmod.pbplugin
is also installed.And then, searching mogenerator GitHub Issues for "uninstall," I found official instructions on how to uninstall mogenerator from the creator himself.
使用 mogenerator:
下载mogenerator
运行并构建 mogenerator 项目
在产品组中找到构建的文件
将构建的文件复制到
/usr/bin
目录< /p>/usr/bin
目录中,复制此代码并按 Enter 键:mogenerator -m /Users/hashem/Desktop/Projects/myApp/myAppModel.xcdatamodel -O /Users/hashem/Desktop/Projects/myApp/managedObjects --template-var arc=true
注意:这里首先我输入了myApp.xcdatamodel文件路径,下一个路径是生成文件的位置。如果文件路径包含空格字符,请务必在文件路径中的空格前添加
\
字符。就像/desktop/xcode\projects/myApp/....
享受吧!
using mogenerator:
download mogenerator
run and build the mogenerator project
locate the built file in the product group
copy the built file in to
/usr/bin
directorymogenerator -m /Users/hashem/Desktop/Projects/myApp/myAppModel.xcdatamodel -O /Users/hashem/Desktop/Projects/myApp/managedObjects --template-var arc=true
NOTE: here first I have entered myApp.xcdatamodel file path, and next path is the location of generated files. if the file path contains space character be sure to add
\
character before space in the file path. like/desktop/xcode\ projects/myApp/....
enjoy!