Closed manavgabhawala closed 7 years ago
I believe the default for Xcode is that everything is spaces (by default 4), but Xcode does go a great distance to make them feel like tabs. I have been using these default settings since I started making apps, and I expect most others to as well since people often don't change the defaults.
However, I am not opposed to switching to tabs since they are more flexible for someone who prefers two-space tabs. If we switch we just need to make sure everyone switches to avoid mucking up the codebase.
^ Agreed. The problem is the code base is already "mucked up" in terms of tabs and spaces!
I went into another Xcode project's settings and changed the indentation type and spacing to see what happens. The problem is this data is stored in the pbxproj file which needs to be tracked by git to maintain project consistency, so these preference will be synced to everyone, defeating the purpose of using tabs.
My recommendation is to stick the default of using 4 spaces for tab and indention, since I suspect most people have these settings already and are the standard for presenting Swift code (look at GitHub formatting or any other website).
No even though tabs/spaces is stored in the pbxproj file Xcode will display depending on the user's preference. That's why I prefer this method. The pbxproj file only dictates whether Xcode will insert spaces or tabs when you hit the enter key. Also the 4 default is not a "standard", the Swift standard library uses 2 spaces! Tabs are great because they get rid of this need to decide what size indent is right, each one to their own.
Upon inspection the standard library does have two spaces - I stand corrected! However, all online documentation in both Swift and ObjC as far as I know is four spaces.
Nonetheless, thank you for helping me understand how the sidebar menu works. I fully agree now that tabs is the way to go, and everyone can define their own viewing options in Xcode preferences. If you would like to go ahead and make the changes the affect the pbxproj file, go ahead.
The other issue you brought up was putting braces on new lines. My preference would be to never do this (not for struct/class definitions, not for function definitions, not for if/else statements - never) because all Swift code in Apple's documentation AND in the standard library AFAIK places opening curly braces at the end of the previous line.
After discussion we've decided sticking with a style most similar to Apple's documentation would be most approachable for new people working on the codebase in the future.
I don't know why this is still open. Seems like we decided it.
The age old debate between which one is better will continue, however we need to pick one (tab or space and if space the width of indentation) and also whether braces go on new lines or not for consistency. Our code base is littered with both uses. Cleaning it up to unify to one style would be great! I would prefer using tabs (this is better cause then users can specify the width they wish to see it at instead of being stuck with a predefined 4 or how many ever we choose spaces). I also prefer braces on a new line but this is a personal preference, whomever decides to clean this up decides I guess.