如何使用 Mogenerator?

发布于 2024-09-15 12:57:47 字数 772 浏览 5 评论 0原文

我安装了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

久夏青 2024-09-22 12:57:47

需要注意的另一件事是:您必须已将实体的 Class 属性设置为与 NSManagedObject 不同的属性。否则 Xmo'd 将不会做任何事情。

注意:据我所知,Xmo'd 目前不适用于 Xcode 4/5。

我所做的只是在 Xcode 中添加一个“MOGenerator”目标:

  1. 转到您的项目并单击“目标”部分中的“添加目标...”。
  2. 选择“iOS -> Other -> Aggregate”
  3. 转到“Build Phases”
  4. 从菜单中选择“Editor -> Add Build Phase -> Add Run Script Build Phase” 将
  5. MOGenerator 命令粘贴到 Run Script 部分,以便示例:
PATH=${PATH}:/usr/local/bin    
cd "${PROJECT_DIR}/MyApp"
mogenerator --human-dir Classes --machine-dir MOGenerated --model MyApp.xcdatamodeld/MyApp.xcdatamodel --template-var arc=true

现在您只需运行此目标即可更新 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:

  1. Go to your project and click on "Add Target..." in the "Targets" section.
  2. Choose "iOS -> Other -> Aggregate"
  3. Go to "Build Phases"
  4. Select from the Menu "Editor -> Add Build Phase -> Add Run Script Build Phase"
  5. Paste your MOGenerator command into the Run Script section, for example:
PATH=${PATH}:/usr/local/bin    
cd "${PROJECT_DIR}/MyApp"
mogenerator --human-dir Classes --machine-dir MOGenerated --model MyApp.xcdatamodeld/MyApp.xcdatamodel --template-var arc=true

Now you can update your MOGenerator-generated by simply running this target.

姐不稀罕 2024-09-22 12:57:47

我记得 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.

淡莣 2024-09-22 12:57:47

我搜索了我的硬盘并找到了以下文件:

该应用程序安装到:/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.

隔岸观火 2024-09-22 12:57:47

⌘我不再在 Xcode 4 中工作。请查看命令行工具。这是文档

⌘I doesn't work in Xcode 4 any more. please check out the command line tool. Here is the doc

谢绝鈎搭 2024-09-22 12:57:47

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.

够运 2024-09-22 12:57:47

使用 mogenerator:

  1. 下载mogenerator

  2. 运行并构建 mogenerator 项目

  3. 在产品组中找到构建的文件
    在此处输入图像描述

  4. 将构建的文件复制到 /usr/bin 目录< /p>

  5. 终端中的 /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:

  1. download mogenerator

  2. run and build the mogenerator project

  3. locate the built file in the product group
    enter image description here

  4. copy the built file in to /usr/bin directory

  5. in the terminal copy this code and hit enter:
    mogenerator -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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文