Automatically Remove Unused #import Directives
Automatically Remove Unused #import Directives
- Subject: Automatically Remove Unused #import Directives
- From: Jerry Krinock <email@hidden>
- Date: Mon, 27 Oct 2008 22:38:07 -0700
After major remodeling of a project, I'm going to have about a hundred
files with an average of maybe 20 #import directives at the top of
each one, and half of them will be no longer necessary since the
symbols that required them were removed or moved to other files during
remodeling.
Of course a good remodel will many remove spaghetti dependencies, but
the un/necessary #imports may still be rather tedious to discern by
inspection.
Is there any script or other automatic means for removing the #import
directives that are no longer needed?
Thanks,
Jerry Krinock
P.S. It seems that a brute-force algorithm exists:
For each .m file in project,
Remove all the #imports,
Compile
Count number of errors/warnings
Repeat with each removed #import:
Restore it
Compile
Count number of errors/warnings
If fewer, leave this #import restored
Else, remove it permanently
}
}
Maybe some re-repeating or recursion would be necessary, but probably
running such a thing all night would achieve upper-90s percent accuracy.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden