Member-only story

Elegantly Tidy Up Our Swift Code in XCode

But how elegant?

Kevin Jonathan
3 min readDec 5, 2022
Photo by Maxwell Nelson on Unsplash

Non-Medium Members can read the full story here.

Most of iOS teams are having a hard time tidying up their code. It’s because some of the team members are probably not following Swift code convention or using their own style of code (especially junior engineers) because they tend to forget or don’t know about Swift’s code conventions.

Not going to lie, I was one of those junior engineers, when I was new in Swift programming.

But I found some tricks that the XCode provided, and those tricks made my life easier. Of course, I won’t need to tidy up my code that often, because I am already enforcing myself to follow Swift’s or my team’s code convention. But these tricks might be helpful for us in common cases.

These are the 2 simple tricks that I found, and enough to help us in the long run for tidying up our Swift code.

Reindenting

XCode has its own reindenting function by using Control + I. We can reindent our entire code in a file (by using Command + A), or just reindenting some of our code (by selecting the area of code). After selecting our code, just press Control + I, and it works like a magic!

--

--

Kevin Jonathan
Kevin Jonathan

Written by Kevin Jonathan

Just a student intricately weaving personal life experience and technology related stuffs, currently navigating the intersections of life.

No responses yet