Keep your iOS projects healthy
How to keep iOS codebase niceLast updated: December 28, 2019
Keeping your code and projects is the best thing you can do to your projects and here’s how to do it your iOS projects written in swift.
Following style guide
There are several style guide for writing swift, and every team member should follow them well. Such as
Using tools
In reality not everyone does it properly so there should be a way to enforce it amongst team members, a way of doing is manual code review which is very time-consuming and code review should happen in logic level not how a developer should declare variable or indentation, we could simple automate these things and invest our time more on harder things.
- Swiftlint will excellently lint the swift codes.
- You can also add linting for storyboard and xib files with xiblint
- It is also preferred to have a one way of formatting code like how many indents, way declaring variable etc and this is where Swiftformat shines really well.
- To Eliminate Unused Swift Code go for periphery
- Having a static analysis of your codes is a good way to have fewer bugs, Infer is a static analysis tool that produces a list of potential bugs.
- You can also automate using these tools on Continuous Integration level using danger. You can use Danger to codify your teams’ norms. Leaving humans to think about harder problems. And danger supports Circle, Travis, Jenkins, Buildkite, BuddyBuild, Semaphore, TeamCity, Xcode Bots, Drone, Surf and Bitrise.
- Pecker is a tool to automatically detect unused code.
Organising Xcode projects
In older versions of Xcode you could only group and in beneath there was no folder structure so basically every file used to stay in one single folder by default and this is messy!