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

Parse connections from Interface Builder files. #212

Open
ileitch opened this issue Nov 25, 2020 · 8 comments
Open

Parse connections from Interface Builder files. #212

ileitch opened this issue Nov 25, 2020 · 8 comments
Labels
enhancement New feature or request

Comments

@ileitch
Copy link
Contributor

ileitch commented Nov 25, 2020

This is need so that we can identify individual unused @ib* declarations.

@ileitch ileitch added the enhancement New feature or request label Nov 25, 2020
@5sw
Copy link

5sw commented Dec 7, 2020

I would like to see that as well. Not just for actions and outlets, but also for classes.

Maybe even distinguishing between top level objects and views nested deeper in the hierarchy. If a class referenced by a top level object from a nib is otherwise unused the chances are good that we can remove the whole class and the nib.

@ileitch
Copy link
Contributor Author

ileitch commented Dec 7, 2020

Classes referenced by nibs are already parsed out, this issue is only for the IB* declarations. Currently what Periphery does is find all classes referenced in a nib, and then blindly retains all of its IB* declarations. So if you've a view controller no longer referenced by a nib, Periphery should detect that it's unused, provided it's not also referenced by other code.

@5sw
Copy link

5sw commented Dec 8, 2020

I see. Currently I have this case: I have a UIView subclass that is placed inside a xib file, but not referenced by code at all. There are also no IBActions or IBOutlets. Periphery marks this class as unused. If periphery is parsing IB files anyways it should be easy to mark this class as used too. Or do you think this should be a separate issue?

@ileitch
Copy link
Contributor Author

ileitch commented Dec 8, 2020

Yes that sounds like a bug. Can you show me the contents of the xib? Also, is the xib a member of the build targets passed to --targets?

@5sw
Copy link

5sw commented Dec 10, 2020

That was it, I forgot to add the resource bundle target. This also resolved my issues from #234.

@monchote
Copy link

If periphery is parsing IB files anyways it should be easy to mark this class as used too.

Is there a way to get the opposite behaviour?

I'm working on a project where every UIView or UIViewController has an associated xib file. For example: as the UIView subclass declared in MyView.swift is referenced by MyView.xib, Periphery doesn't mark MyView as unused, even though it never gets instantiated anywhere else in the codebase.

I've tried --index-exclude "*.xib" but it didn't help.

@ileitch
Copy link
Contributor Author

ileitch commented Jul 15, 2021

Yeah index excluding is only hooked up for Swift files currently. Could you open a new issue for this, and I'll implement it when I get a chance.

@KRUBERLICK
Copy link

KRUBERLICK commented Aug 23, 2024

I have an SPM target with a .xib and a corresponding View class as the nib's File Owner. All of @IBActions are marked as unused after the scan. All targets are included via the all choice in periphery scan --setup. Can anyone help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants