Xcode 4 and Xmo’d compatibility #48

Closed
MonsieurDart opened this Issue Feb 23, 2011 · 28 comments

Comments

Projects
None yet
@MonsieurDart

Now that Apple is trying to force us to use Xcode 4, I'm in front of a problem: it seems Xmo'd doesn't work with this major Xcode release. Is there a solution for that out there? If not, are you planning on adding the support for Xcode 4 anytime soon? Can I help on that?

@rentzsch

This comment has been minimized.

Show comment
Hide comment
@rentzsch

rentzsch Feb 24, 2011

Owner

Yup, Xmo'd doesn't work with Xcode 4 since v4 doesn't load .pbplugins any more. This looks interesting as a way to migrate Xmo'd to an .xcplugin.

Once loaded, the next obstacle is to discover whether swizzling -[XDPersistenceDocumentController saveModelToFile:] is still the best way to get notifications of model file changes.

Finally, how much you wanna bet Apple changed/broke Xcode's AppleScript interface, so chances are there's work to be done there as well.

If Xcode seriously breaks the AppleScript interface again, I'm of the opinion that a pure Obj-C implementation would be preferable. We'd have to use a lot more internal APIs, but Xcode's internal APIs are more stable and make more sense than their AppleScript interface,

Owner

rentzsch commented Feb 24, 2011

Yup, Xmo'd doesn't work with Xcode 4 since v4 doesn't load .pbplugins any more. This looks interesting as a way to migrate Xmo'd to an .xcplugin.

Once loaded, the next obstacle is to discover whether swizzling -[XDPersistenceDocumentController saveModelToFile:] is still the best way to get notifications of model file changes.

Finally, how much you wanna bet Apple changed/broke Xcode's AppleScript interface, so chances are there's work to be done there as well.

If Xcode seriously breaks the AppleScript interface again, I'm of the opinion that a pure Obj-C implementation would be preferable. We'd have to use a lot more internal APIs, but Xcode's internal APIs are more stable and make more sense than their AppleScript interface,

@vguerci

This comment has been minimized.

Show comment
Hide comment
@vguerci

vguerci Feb 24, 2011

Contributor

I tried to port AppleScript for Xcode 4. It can be done, but that's awful... I guess Applescript coding is not completed yet. Imho, that GM of Xcode 4 is anyway more a RC / Beta than a gold. But I still prefer it and use it.
For now, I use mogenerator from command line... (and if really needed use Xmod from v3)

That Xcode plugin template is quite empty and pretty useless... :( but i agree native plugin is THE way. AppleScript, you know, bleh. Xcode internal APIs are not documented, isn't?

Contributor

vguerci commented Feb 24, 2011

I tried to port AppleScript for Xcode 4. It can be done, but that's awful... I guess Applescript coding is not completed yet. Imho, that GM of Xcode 4 is anyway more a RC / Beta than a gold. But I still prefer it and use it.
For now, I use mogenerator from command line... (and if really needed use Xmod from v3)

That Xcode plugin template is quite empty and pretty useless... :( but i agree native plugin is THE way. AppleScript, you know, bleh. Xcode internal APIs are not documented, isn't?

@MonsieurDart

This comment has been minimized.

Show comment
Hide comment
@MonsieurDart

MonsieurDart Feb 24, 2011

Thanks for your quick help guys! I'll do as you do: use the command line, or maybe add it to the target if I need it to be automatized...

Thanks for your quick help guys! I'll do as you do: use the command line, or maybe add it to the target if I need it to be automatized...

@vguerci

This comment has been minimized.

Show comment
Hide comment
@vguerci

vguerci Mar 6, 2011

Contributor

Side note, GTM provides a xcplugin source code, with class-dump-ed Xcode headers...
A good base to start a mogenerator plugin imho :)
http://code.google.com/p/google-toolbox-for-mac/source/browse/#svn/trunk/XcodePlugin

Contributor

vguerci commented Mar 6, 2011

Side note, GTM provides a xcplugin source code, with class-dump-ed Xcode headers...
A good base to start a mogenerator plugin imho :)
http://code.google.com/p/google-toolbox-for-mac/source/browse/#svn/trunk/XcodePlugin

@prime31

This comment has been minimized.

Show comment
Hide comment
@prime31

prime31 Mar 11, 2011

Has anyone come up with a solution to the AppleScript breaking? The only outstanding issue I see is that a file reference can no longer be added to a build phase (add modelSrcFileRef to targetItr). I have tried everything under the sun to get this to work but have not successfully added a single file to any phase...

prime31 commented Mar 11, 2011

Has anyone come up with a solution to the AppleScript breaking? The only outstanding issue I see is that a file reference can no longer be added to a build phase (add modelSrcFileRef to targetItr). I have tried everything under the sun to get this to work but have not successfully added a single file to any phase...

@vguerci

This comment has been minimized.

Show comment
Hide comment
@vguerci

vguerci Mar 11, 2011

Contributor

Could you gist your changes? I would help with pleasure.
Last attempt I did on Beta was horrible, Applescript API wasn't done, from what I've just seen, it looks now more complete...

Contributor

vguerci commented Mar 11, 2011

Could you gist your changes? I would help with pleasure.
Last attempt I did on Beta was horrible, Applescript API wasn't done, from what I've just seen, it looks now more complete...

@prime31

This comment has been minimized.

Show comment
Hide comment
@prime31

prime31 Mar 11, 2011

vguerci, I don't have any changes to gist. Everything I tried failed. I tried manually creating the build files which didnt work, creating the file references while in the context of the build phase and anything else I could think of all failed.

prime31 commented Mar 11, 2011

vguerci, I don't have any changes to gist. Everything I tried failed. I tried manually creating the build files which didnt work, creating the file references while in the context of the build phase and anything else I could think of all failed.

@vguerci

This comment has been minimized.

Show comment
Hide comment
@vguerci

vguerci Mar 11, 2011

Contributor

I've just gave a look into Xcode 4 Applescript... Thought it was better than beta, it is not. Still a terrible mess I think... But maybe I'm missing something.
Where you could simply get xmod data model by using:
set modelList to every file reference of _project whose file kind is "wrapper.xcdatamodel" and comments contains "xmod", you now have (like in Xcode beta) to recursive browse groups / items hierarchy to get it. (please tell me I'm wrong)

There is a (new?) appealing Xcode application > data model property, which just brings... nothing.
And those To be removed suite and Xcode 3 xxxx types are just... scary.
I don't think I'll look further in this for a while... maybe at next Xcode version or maybe directly in a native coded obj-c .xcplugin...

Contributor

vguerci commented Mar 11, 2011

I've just gave a look into Xcode 4 Applescript... Thought it was better than beta, it is not. Still a terrible mess I think... But maybe I'm missing something.
Where you could simply get xmod data model by using:
set modelList to every file reference of _project whose file kind is "wrapper.xcdatamodel" and comments contains "xmod", you now have (like in Xcode beta) to recursive browse groups / items hierarchy to get it. (please tell me I'm wrong)

There is a (new?) appealing Xcode application > data model property, which just brings... nothing.
And those To be removed suite and Xcode 3 xxxx types are just... scary.
I don't think I'll look further in this for a while... maybe at next Xcode version or maybe directly in a native coded obj-c .xcplugin...

@rentzsch

This comment has been minimized.

Show comment
Hide comment
@rentzsch

rentzsch Mar 12, 2011

Owner

vguerci and prime31:

I really appreciate you guys digging into this. The first time I'll have to look at this is late next week. Godspeed on your efforts :-)

Owner

rentzsch commented Mar 12, 2011

vguerci and prime31:

I really appreciate you guys digging into this. The first time I'll have to look at this is late next week. Godspeed on your efforts :-)

@noirs

This comment has been minimized.

Show comment
Hide comment
@noirs

noirs May 16, 2011

Any news regarding Xmo'd Xcode 4 compatibility?

noirs commented May 16, 2011

Any news regarding Xmo'd Xcode 4 compatibility?

@marzapower

This comment has been minimized.

Show comment
Hide comment
@marzapower

marzapower May 25, 2011

I too am in the list of those who carefully await for your hard work to be completed! Any news?

I too am in the list of those who carefully await for your hard work to be completed! Any news?

@vguerci

This comment has been minimized.

Show comment
Hide comment
@vguerci

vguerci May 25, 2011

Contributor

I'm afraid doing an Xcode 4 plugin with that no so documented API is not that easy.
And that could easily break with Xcode versions upgrades...

That's really a weak point of Xcode, Visual Studio in comparison has tons of wonderful add-ons thanks to its (probably documented) API.

I'm still using command-line, with manually adding files to Xcode project... still a good productivity boost. :)

Contributor

vguerci commented May 25, 2011

I'm afraid doing an Xcode 4 plugin with that no so documented API is not that easy.
And that could easily break with Xcode versions upgrades...

That's really a weak point of Xcode, Visual Studio in comparison has tons of wonderful add-ons thanks to its (probably documented) API.

I'm still using command-line, with manually adding files to Xcode project... still a good productivity boost. :)

@marzapower

This comment has been minimized.

Show comment
Hide comment
@marzapower

marzapower May 29, 2011

I'm using the command line tool too, and that's not bad! I think it will suffice, thank you!

I'm using the command line tool too, and that's not bad! I think it will suffice, thank you!

@mknippen

This comment has been minimized.

Show comment
Hide comment
@mknippen

mknippen Jun 14, 2011

have we found any solution to this? If not, is there a good place for documentation on the command line tool version?
With Xcode 3 pretty much gone, this will soon be our only option.

have we found any solution to this? If not, is there a good place for documentation on the command line tool version?
With Xcode 3 pretty much gone, this will soon be our only option.

@marzapower

This comment has been minimized.

Show comment
Hide comment
@marzapower

marzapower Jun 14, 2011

The best guide I've found to the command line tool is at this page:
http://stackoverflow.com/questions/3589247/how-do-the-mogenerator-parameters-work-which-can-i-send-via-xcode

I do not think anyone has ported this project to Xcode 4 yet. The command
line tool works just great, by the way!

2011/6/14 mknippen <
reply@reply.github.com>

have we found any solution to this? If not, is there a good place for
documentation on the command line tool version?
With Xcode 3 pretty much gone, this will soon be our only option.

Reply to this email directly or view it on GitHub:
#48 (comment)

The best guide I've found to the command line tool is at this page:
http://stackoverflow.com/questions/3589247/how-do-the-mogenerator-parameters-work-which-can-i-send-via-xcode

I do not think anyone has ported this project to Xcode 4 yet. The command
line tool works just great, by the way!

2011/6/14 mknippen <
reply@reply.github.com>

have we found any solution to this? If not, is there a good place for
documentation on the command line tool version?
With Xcode 3 pretty much gone, this will soon be our only option.

Reply to this email directly or view it on GitHub:
#48 (comment)

@Burnsoft

This comment has been minimized.

Show comment
Hide comment
@Burnsoft

Burnsoft Jun 15, 2011

for those that have mogenerator working via command line in xcode 4, can you put together a very simplistic dummies guide? would be very much appreciated.

for those that have mogenerator working via command line in xcode 4, can you put together a very simplistic dummies guide? would be very much appreciated.

@rentzsch

This comment has been minimized.

Show comment
Hide comment
@rentzsch

rentzsch Jun 15, 2011

Owner

burnsoft: mogenerator --help gives pretty-good list of mogenerator's arguments. Personally, before Xmo'd, I used to keep a mogenerate.command double-clickable shell script that I would manually run after modifying a model. Here's an example mogenerate.command file.

Owner

rentzsch commented Jun 15, 2011

burnsoft: mogenerator --help gives pretty-good list of mogenerator's arguments. Personally, before Xmo'd, I used to keep a mogenerate.command double-clickable shell script that I would manually run after modifying a model. Here's an example mogenerate.command file.

@danieldickison

This comment has been minimized.

Show comment
Hide comment
@danieldickison

danieldickison Jun 15, 2011

I've been creating a separate Xcode build target that contains just a shell script build phase to run the command line tool. It's pretty quick to switch to that target after making any model changes.

But adding and removing new and deleted .h and .m files from the project is still a manual process. Is there any way to automate those short of an Xcode plugin?

I've been creating a separate Xcode build target that contains just a shell script build phase to run the command line tool. It's pretty quick to switch to that target after making any model changes.

But adding and removing new and deleted .h and .m files from the project is still a manual process. Is there any way to automate those short of an Xcode plugin?

@rentzsch

This comment has been minimized.

Show comment
Hide comment
@rentzsch

rentzsch Jun 15, 2011

Owner

danieldickison: check out the --includem and master's --includeh options

Owner

rentzsch commented Jun 15, 2011

danieldickison: check out the --includem and master's --includeh options

@Burnsoft

This comment has been minimized.

Show comment
Hide comment
@Burnsoft

Burnsoft Jun 15, 2011

ok, so I'm in the folder where my model is:
mogenerator --model myModel.xcdatamodeld --base-class People
but I get this:
Assertion failed: (model), function -[MOGeneratorApp setModel:], file /Users/wolf/code/github/mogenerator/mogenerator.m, line 432.
Abort trap

any ideas?

ok, so I'm in the folder where my model is:
mogenerator --model myModel.xcdatamodeld --base-class People
but I get this:
Assertion failed: (model), function -[MOGeneratorApp setModel:], file /Users/wolf/code/github/mogenerator/mogenerator.m, line 432.
Abort trap

any ideas?

@Burnsoft

This comment has been minimized.

Show comment
Hide comment
@Burnsoft

Burnsoft Jun 15, 2011

and am I correct in assuming that mogenerator will create both the Model and _Model files if I just use
mogenerator --model myModel.xcdatamodeld

?
thanks for all the help so far.

and am I correct in assuming that mogenerator will create both the Model and _Model files if I just use
mogenerator --model myModel.xcdatamodeld

?
thanks for all the help so far.

@marzapower

This comment has been minimized.

Show comment
Hide comment
@marzapower

marzapower Jun 15, 2011

You have to point to the correct model, not the parent directory. I.e.
something like this:

mogenerator --model myModel.xcdatamodeld/myModel.xcdatamodel

2011/6/15 Burnsoft <
reply@reply.github.com>

and am I correct in assuming that mogenerator will create both the Model
and _Model files if I just use
mogenerator --model myModel.xcdatamodeld

?
thanks for all the help so far.

Reply to this email directly or view it on GitHub:
#48 (comment)

You have to point to the correct model, not the parent directory. I.e.
something like this:

mogenerator --model myModel.xcdatamodeld/myModel.xcdatamodel

2011/6/15 Burnsoft <
reply@reply.github.com>

and am I correct in assuming that mogenerator will create both the Model
and _Model files if I just use
mogenerator --model myModel.xcdatamodeld

?
thanks for all the help so far.

Reply to this email directly or view it on GitHub:
#48 (comment)

@Burnsoft

This comment has been minimized.

Show comment
Hide comment

thankyou

@vguerci

This comment has been minimized.

Show comment
Hide comment
@vguerci

vguerci Jun 15, 2011

Contributor

Here is a small script I use that auto pick current version of a versioned model, that could help :

modeld=MyApp.xcdatamodeld
modelversion=$(/usr/libexec/PlistBuddy -c 'print _XCCurrentVersionName' $modeld/.xccurrentversion)
model=$modeld/$modelversion
echo "Mo'Generating code for $model..."
mogenerator -m "$model"\
 --base-class MyBaseManagedObject\
 --template-path templates\
 --machine-dir Generated\
 --includeh MyModelEntities.h
Contributor

vguerci commented Jun 15, 2011

Here is a small script I use that auto pick current version of a versioned model, that could help :

modeld=MyApp.xcdatamodeld
modelversion=$(/usr/libexec/PlistBuddy -c 'print _XCCurrentVersionName' $modeld/.xccurrentversion)
model=$modeld/$modelversion
echo "Mo'Generating code for $model..."
mogenerator -m "$model"\
 --base-class MyBaseManagedObject\
 --template-path templates\
 --machine-dir Generated\
 --includeh MyModelEntities.h
@larsxschneider

This comment has been minimized.

Show comment
Hide comment
@larsxschneider

larsxschneider Nov 28, 2011

I wrote an Xcode plugin that might help with the situation: https://github.com/larsxschneider/Xcode-Scripting-Interface
What project modifications do you want to perform? I can add them!

I wrote an Xcode plugin that might help with the situation: https://github.com/larsxschneider/Xcode-Scripting-Interface
What project modifications do you want to perform? I can add them!

@adib

This comment has been minimized.

Show comment
Hide comment
@adib

adib Nov 28, 2011

Here is a script that I use to update the generated files. Put this in a subfolder of your project (like BuildScripts for example)

#!/bin/sh

#  update_mo.sh
#  Updates Core Data generated classes - requires mogenerator
#
#  Created by Sasmito Adibowo on 28-11-11.

baseClass=NSManagedObject

function update_model()
{

    fileDir=`dirname "${1}"`
    curVer=`/usr/libexec/PlistBuddy "${1}/.xccurrentversion" -c 'print _XCCurrentVersionName'`

    echo mogenerator  --model "${1}/$curVer" --output-dir "${fileDir}/" --base-class $baseClass  --template-var arc=true
    mogenerator  --model "${1}/$curVer" --output-dir "${fileDir}/" --base-class $baseClass  --template-var arc=true
}

find .. -iname \*.xcdatamodeld -print0 | while read -d $'\0' i; do update_model "$i"; done

adib commented Nov 28, 2011

Here is a script that I use to update the generated files. Put this in a subfolder of your project (like BuildScripts for example)

#!/bin/sh

#  update_mo.sh
#  Updates Core Data generated classes - requires mogenerator
#
#  Created by Sasmito Adibowo on 28-11-11.

baseClass=NSManagedObject

function update_model()
{

    fileDir=`dirname "${1}"`
    curVer=`/usr/libexec/PlistBuddy "${1}/.xccurrentversion" -c 'print _XCCurrentVersionName'`

    echo mogenerator  --model "${1}/$curVer" --output-dir "${fileDir}/" --base-class $baseClass  --template-var arc=true
    mogenerator  --model "${1}/$curVer" --output-dir "${fileDir}/" --base-class $baseClass  --template-var arc=true
}

find .. -iname \*.xcdatamodeld -print0 | while read -d $'\0' i; do update_model "$i"; done
@rentzsch

This comment has been minimized.

Show comment
Hide comment
@rentzsch

rentzsch Nov 28, 2011

Owner

larsxschneider: thanks for the offer, but if it comes down to bypassing AppleScript and using Xcode internals to update group files, I'd prefer if Xmo'd did that directly. But I'll probably be able to poach from your code, thanks!

Owner

rentzsch commented Nov 28, 2011

larsxschneider: thanks for the offer, but if it comes down to bypassing AppleScript and using Xcode internals to update group files, I'd prefer if Xmo'd did that directly. But I'll probably be able to poach from your code, thanks!

@justin

This comment has been minimized.

Show comment
Hide comment
@justin

justin Dec 26, 2015

Collaborator

Xmod is RIP.

Collaborator

justin commented Dec 26, 2015

Xmod is RIP.

@justin justin closed this Dec 26, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment