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

Cyclical dependencies warning #105

Closed
caramdache opened this issue Sep 23, 2018 · 8 comments
Closed

Cyclical dependencies warning #105

caramdache opened this issue Sep 23, 2018 · 8 comments

Comments

@caramdache
Copy link

It's been a while since I compiled one of my projects and it suddenly raises warnings for possible cyclical dependencies. A while later, CoreData complains that some dynamic accessors cannot be resolved.

Build ./build/iPhoneSimulator-12.0-Development
WARNING! Possible cyclical dependency between ./app/about_controller.rb and ./app/events_controller.rb's class hierarchy. Consider revision if runtime exceptions occur around undefined symbols.
WARNING! Possible cyclical dependency between ./../lib/UITableViewTextFieldCell.rb and ./app/events_controller.rb's class hierarchy. Consider revision if runtime exceptions occur around undefined symbols.
WARNING! Possible cyclical dependency between ./app/event_controller.rb and ./app/events_controller.rb's class hierarchy. Consider revision if runtime exceptions occur around undefined symbols.
Compile ./../lib/UIColor_extensions.rb
Compile ...
Simulate /Users/home/Source/Events/build/iPhoneSimulator-12.0-Development/Events.app
(main)> CoreData: warning: dynamic accessors failed to find @property implementation for 'date' for entity 'Event' while resolving selector 'date' on class 'Event'.  Did you remember to declare it @dynamic or @synthesized in the @implementation ?

Intriguing, because these issues were never raised before by earlier version of RM. All the more intriguing that another project that follows a similar template (same class structure, same use of core data, use of the same RM lib, etc.) compiles and runs just fine.

Could this be a bug in RM 5.14 ?

@caramdache caramdache changed the title Cyclical dependencies Unexpected cyclical dependencies warning Sep 23, 2018
@caramdache caramdache changed the title Unexpected cyclical dependencies warning Cyclical dependencies warning Sep 23, 2018
@amirrajan
Copy link
Owner

The cyclical dependency warning was added last as part of the build process to bring attention to them. Your project may have always had them (or gems you depended on), this just brings them to light and become more important if you end up monkey patching classes that have cyclical dependencies.

@caramdache
Copy link
Author

caramdache commented Sep 24, 2018

I've been trying to understand the error message and so I've included the code that you published earlier at: https://github.com/rubymotion/motion-support/issues/38#issuecomment-366676898.

However, in cyclic?, only file paths are available. Is there any way to find out the class(es) that trigger the cyclic dependency?

Besides, when I use defined?, RM print a duplicate warning for that file. Is this not supposed to turn the warning/issue off instead?

@amirrajan
Copy link
Owner

Applying the following patch will give you the full graph: jamonholmgren/ProMotion#810

There is also this gem that will let you visualize your dependencies: https://github.com/emad-elsaid/rubrowser

@caramdache
Copy link
Author

caramdache commented Sep 25, 2018

Thanks for the pointers. https://github.com/infinitered/ProMotion/issues/810 only displays dependencies between files, NOT classes, as far as I can see.

rubrowser is excellent, thanks! However, it does not show any dependency between EventsController and AboutController. However, RM points out a circular dependency between ./app/events_controller.rb and ./app/about_controller.rb. Doesn't this look like a possible bug?
capture d ecran 2018-09-25 a 11 16 33

@caramdache
Copy link
Author

run seems like a more appropriate place to display the warning, as there can be multiple classes per file. Here is a suggested patch:

if cyclic?(dependency, def_path, ref_path)
    App.warn("Possible cyclical dependency for #{const} between #{def_path} and #{ref_path}'s. Consider revision if runtime exceptions occur around undefined 
    # remove cyclic 
    next
end

@amirrajan
Copy link
Owner

@caramdache are you monkey patching any gems you depend on?

Make sure you are including files in both app and lib

@caramdache
Copy link
Author

No, but I'm monkey patching quite a few UIKit classes by myself. This is what the lib directory is for.

@amirrajan
Copy link
Owner

Are any of the libraries that you depend on also monkepatching the same UIKit libraries?

I don't think it'll be an issue given that it's all UIKit related. If you want you can email me at [email protected] or DM on the Slack and I can help with your private repo.

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

2 participants