peripheryapp / periphery

A tool to identify unused code in Swift projects.
MIT License
5.02k stars 178 forks source link

NSObject subclasses are not flagged #729

Open scottasoutherland opened 2 months ago

scottasoutherland commented 2 months ago

We are running periphery scan with only the parameters

--workspace , --schemes, --targets , we notice that subclasses of NSObject are not flagged as unused. I know you mention in the README that there is special treatment of objective-c runtime accessible classes, but if I understand it correctly, they should by default be caught unless --retain-objc-accessible is passed or the class is annotated with @objc and --retain-objc-annotated is passed, but this does not appear to be true. To be sure i didn't misunderstand, i did try running with those flags and they still are not caught.

I see there are tests to ensure those flags don't flag obj-c members ( https://github.com/peripheryapp/periphery/tree/master/Tests/Fixtures/ObjcAnnotatedRetentionFixtures ) but I don't see any tests around catching them, but I haven't looked extensively.

ileitch commented 2 months ago

You're correct that it should identify NSObject subclasses by default. Are you seeing this for all subclass or just some? If you can provide an example project that reproduces the issue I can take a look at what's going wrong.

scottasoutherland commented 1 month ago

I spent a little bit of time on this. It seems in very simple cases it works as expected. So it must be something specific to our project setup that is causing it. I'll keep digging.