NijiDigital / gyro

Tool to generate Realm.io models for Swift, Java & ObjC from xcdatamodel and its visual Xcode editor
Apache License 2.0
93 stars 15 forks source link

Improve error message when passing an xcdatamodeld #26

Closed StevenWatremez closed 6 years ago

StevenWatremez commented 7 years ago

When you use gyro with this command line : gyro -m .../Models/DataModel.xcdatamodeld, it fails with error :

! Unable to find contents of xcdatamodel
/Users/steven_watremez/workspace/tools/gyro/lib/gyro/log.rb:42:in `fail!': Unable to find contents of xcdatamodel (RuntimeError)
    from /Users/steven_watremez/workspace/tools/gyro/lib/gyro/parser/xcdatamodel/xcdatamodel.rb:38:in `initialize'
    from bin/gyro:123:in `new'
    from bin/gyro:123:in `<main>'

This is because gyro expects an .xcdatamodel (to look at the contents XML file inside it) and not an .xcdatamodeld. But the error is not very friendly.

A solution to avoid this error would be to raise a specific error like : please target an xcdatamodel inside your xcdatamodeld

💡 In addition for user that use an xcdatamodel which happens to be inside an xcdatamodeld bundle, gyro could raise a warning like: you use an xcdatamodeld, please be sure you target the correct version of your xcdatamodel. Actual version using by gyro is : MyDataModel-V2.xcdatamodel so that people don't forget about updating the command line when they create a new datamodel version