Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift support #284

Closed
skywinder opened this issue May 21, 2015 · 19 comments
Closed

Swift support #284

skywinder opened this issue May 21, 2015 · 19 comments

Comments

@skywinder
Copy link

Hi. I quite confused about swift support.

  1. according this line:
    https://github.com/rentzsch/mogenerator/blob/master/mogenerator.m#L726
    I should write --swift option.
  2. according link in beginning of your readme: http://stackoverflow.com/questions/3589247/how-do-the-mogenerator-parameters-work-which-can-i-send-via-xcode
    there is no mention about swift at all.
  3. also according readme you mention that we should use --v3 option to generate in swift.
    There is also mention about some to-one relationships bug - is there issue related to this bug? how better to track resolution of this bug?
  4. And finally, I found, that you have swift12 branch. Is it better to build your project from this branch to use it in swift project?
@dave256
Copy link
Contributor

dave256 commented May 22, 2015

If you are using Swift 1.2, yes you should use the swift12 branch. That stackoverflow article was written in 2010 and Swift was only announced in 2014.

I use it like this (after cd'ing to the directory where the Core Data model file is):

mogenerator --swift -m ModelFile.xcdatamodeld --base-class DDRManagedObject --base-class-import DDRCoreDataKit --output-dir ./ModelObjects

but if you don't have a standard base class you want the mogenerator files to inherit from, then this should work for you:

mogenerator --swift -m ModelFile.xcdatamodeld --output-dir ./ModelObjects

Obviously replace ModelFile with the name of your Core Data model file.

@skywinder
Copy link
Author

@dave256 👍 thanks for detailed explanation!

It will be nice to mention it in readme, since there a new age of Swift is coming! 😉

@dimazen
Copy link

dimazen commented May 25, 2015

@dave256 how can I install swift12 branch using brew? Can you help me? I'd like to switch my CD files to Swift..)
Thanks in advance!

@dave256
Copy link
Contributor

dave256 commented May 25, 2015

I'm not an official maintainer - I've just provided a few patches to the swift12 branch. I don't know if it's possible to install a specific branch using brew. I initially installed it using brew, but forked and clone the repository to use the new branch.

@skywinder
Copy link
Author

afaik, by brew it's not possible.
Hope guys will merge it to master soon.

@corysullivan
Copy link

@dave256 Hi Dave, curious what type of things you include in your base class. I never knew this was an option. Thanks

@dave256
Copy link
Contributor

dave256 commented May 27, 2015

Various convenience methods for fetching objects

https://github.com/dave256/DDRCoreDataKit/blob/master/DDRCoreDataKit/DDRManagedObject.swift

@corysullivan
Copy link

@dave256 Thanks

@DannyJi
Copy link

DannyJi commented Jun 5, 2015

How do I install the swift12 branch? I am using mogenerator 1.27 for awhile that I installed via a dmg. The new 1.28 DMG will not have this branch and from reading above, does not seem like it is possible via brew. I am just not sure of the technical steps to get the swift12 branch installed.

Also, I am working on my new project that I am trying to be completely in Swift. There is mention of a to-one relationships... for anyone using this branch - how serious is it for development use?

@AverageHelper
Copy link

I agree with Danny and dave256, and would like an answer to both their questions: How would one install the swift12 branch in place of our existing (older) installation without homebrew, and what is this about to-one relationships?

As the answer to both of these queries pertain rather heavily to my application, I would greatly appreciate a response. If no response is forthcoming—assuming either there is no known answer or people simply are unwilling to respond—then I'd still like some information to these ends. Any response at all would be of great assistance to myself, if not to others as well. Thanks in advance!

@dave256
Copy link
Contributor

dave256 commented Jun 16, 2015

@SilverEnderman to install without brew do the following in the Terminal app (bash shell):
git clone git@github.com:rentzsch/mogenerator.git
git checkout feature/swift12

Open the .xcodeproj file in it and build it. I then went to the DerivedData directory
cd ~/Library/Developer/Xcode/DerivedData/
look for the directory with mogenerator in the name
cd into it
and then look for the mogenerator executable
something like
cd Build/Products/Debug
once you find the mogenerator file, copy it somewhere and then use that version in place of the one in /usr/local/bin that brew installed (you could copy it over the one in /usr/local/bin but I'd save that one first).

I'm not sure what to one relationship issue you're referring to.

HTH

@skywinder
Copy link
Author

@dave256 Thanks for step-by-step tutorial! I found, that stable version is also support swift.
Can you explain, what advantages of branch feature/swift12?

@AverageHelper
Copy link

Yes, thanks for the tutorial!

Honestly, I'm not sure what to-one relationship issue I'm referring to either. I was wondering if there was such an issue, as I've heard tale recently of problems with mogenerator and Core Data to-one relationships. I'm fairly new to mogenerator, so if that problem doesn't exist, then I guess there's no point in me rambling on it further!

@DannyJi
Copy link

DannyJi commented Jun 16, 2015

@dave256 ... thanks so much for the instructions. So far I have cloned, checked out, built and copied (as mogeneratorSwift) to my /usr/local/bin. This was not to disturb by version 1.27 (I realize I am behind stable release)

I am more familiar with svn. The only part I am not sure is the checkout of the swift12 branch. I saw no errors.

$ git checkout feature/swift12
Branch feature/swift12 set up to track remote branch feature/swift12 from origin.
Switched to a new branch 'feature/swift12'

After all the build and copy ...

$ mogenerator -version
mogenerator 1.27. By Jonathan 'Wolf' Rentzsch + friends.

$ mogeneratorSwift -version
mogenerator 1.28. By Jonathan 'Wolf' Rentzsch + friends.

So I am pretty confident I can begin to play with the mogen on my Core Data models. I will let you know if have any issues.

@dave256
Copy link
Contributor

dave256 commented Jun 17, 2015

@skywinder version 1.27 was released when Swift 1.0 was current. Apple made some changes to the language for Swift 1.2 so the feature/swift12 is to work better with Swift 1.2. You can read the changelog here: https://github.com/rentzsch/mogenerator/commits/feature/swift12

Again, I'm not an official maintainer so I certainly don't speak for the maintainers of the project. I just ran into some of the issues when trying to use version 1.27 with Swift 1.2 so I forked the repository, worked on fixing them, submitted pull requests, and they were accepted by one of the maintainers. Others have also contributed to the swift12 branch.

@skywinder
Copy link
Author

@dave256 Awesome-awesome! 👍 Don't stop, Swift 2.0 ahead! 😉
@rentzsch Is there any blockers to not merge feature/swift12 branch to master?

@tomburns
Copy link
Contributor

👍 for getting feature/swift12 merged; can I contribute somehow or is it just waiting on maintainer review?

@leoyvens
Copy link
Contributor

I've been using feature/swift12 for a few months in production and it's working fine in my experience.

@tomburns
Copy link
Contributor

Are ordered relationships just ignored by the current swift templates? I'm using the feature/swift12 branch and ending up with plain old NSSets in my generated classes.

edit: Created #290 to represent this issue

@skywinder skywinder changed the title Swift support (genereal) Swift support Jun 24, 2015
@justin justin closed this as completed Dec 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants