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

IBActions reported as unused #234

Closed
Servus7 opened this issue Dec 7, 2020 · 7 comments
Closed

IBActions reported as unused #234

Servus7 opened this issue Dec 7, 2020 · 7 comments

Comments

@Servus7
Copy link

Servus7 commented Dec 7, 2020

All IBActions In our project are incorrectly marked as not used. IBInspectable and IBOutlet however are marked only if unused.
What could be the difference resulting in all IBActions being false positives?

@ileitch
Copy link
Contributor

ileitch commented Dec 7, 2020

Servus 👋

That certainly shouldn't be happening. We've already test coverage for IBAction: https://github.com/peripheryapp/periphery/blob/master/Tests/XcodeTests/iOSProject/iOSProject/XibViewController.swift#L4-L7 So there must be something a little different about your usage.

Could you take a look again and see if there's any special about the way you're using IBAction perhaps? If not, please provide an example.

@5sw
Copy link

5sw commented Dec 7, 2020

I see the same issue if my @IBAction is private. Same happens for @objc, gets marked as unused as soon as it is private.

@sdc-78
Copy link

sdc-78 commented Dec 7, 2020

In my project, I don't have false positives for my private @IBAction.

@ileitch
Copy link
Contributor

ileitch commented Dec 7, 2020

I see the same issue if my @IBAction is private.

I'm also unable to reproduce this by making them private.

Same happens for @objc, gets marked as unused as soon as it is private. Are you talking about methods in general, or only @IBAction methods?

Are you using the new --retain-objc-accessible option? If so, I believe I've identified a bug with that: #238

@Servus7
Copy link
Author

Servus7 commented Dec 8, 2020

I added --retain-objc-accessible and the false positives are gone. Thank You! I'll start removing unused code.
EDIT: Private IBActions are still reported unused

@ileitch
Copy link
Contributor

ileitch commented Dec 8, 2020

@Servus7 That option is only intended for use with mixed Swift/Objc projects. It shouldn't be used just to fix IBAction false positives. If a class is referenced by a nib, then it's IBActions should also be identified as used.

Do you have any instances of IBAction being reported as unused in a class that also has IBOutlet/Inspectable that aren't being reported as unused? If so, please provide as much code as possible from this class so that I may diagnose.

@Servus7
Copy link
Author

Servus7 commented Dec 10, 2020

We were using Resources Bundles and doesn't added them to periphery scan 🤦🏻‍♂️

@Servus7 Servus7 closed this as completed Dec 10, 2020
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

4 participants