Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcode replaces tabs by spaces after a branch merge

After a merge of two branches, and resolving conflicts, Xcode modifies two files: the .plist and the .pbxproj of the project. In both cases, the leading tabs of every line are replaced by spaces.

Also after finishing the merge and creating the corresponding commit, Xcode leaves all the files that had conflicts without adding them to the commit, forcing us to make a second commit with the resolved files (including .plist and .pbxproj). Only happens with those two files and only if they have conflicts on the merge, other file types (.h, .m) not affected.

Xcode Version 9.2 (9C40b)

  • The number of spaces added, corresponds to the number of tabs present: 4 spaces per tab.
  • In the Xcode Preferences, all the team have selected "Spaces" in "Prefer indent using: under Indentation.

We would like to know how to avoid this behaviour?

like image 527
veladan Avatar asked Mar 16 '18 14:03

veladan


People also ask

How do I change the branch of a project in Xcode?

The current branch is indicated by the leading “*": If you want to switch between branches from within Xcode you can do that from the Organizer using the appropriately named “Switch Branch” icon in the bottom right corner (again ensure you have the project directory selected in the left-hand pane and not the Branches or Remotes folders):

Does typing a tab result in 4 spaces in Xcode?

Tab key inserts tab, not spaces is unchecked, and Tab width = 4, and Indent width = 4. However, typing a tab does not seem to result in 4 spaces. If I open a *.cpp or *.h file with an internet browser, what appeared nicely aligned in XCode, is now displayed with ragged indentation.

How do I insert a tab in Xcode?

The easiest way to do it in Xcode is to select a code block and then hit ⌘ + [ [ and then ⌘ + ]] for each tab space. Check 'Tab key inserts tab, not spaces'.

Can Xcode manage Git branches?

Since Xcode has the ability to manage Git branches I thought I would take a look and share my experiences in this post. For the purposes of this post I am going to use my CodeExamples repository and create a new branch to experiment with converting one of the example projects to ARC.


1 Answers

Maybe it's because of indentation settings in one of the systems your team use:

enter image description here

If you have swift lint in your project, that's can cause it too.

like image 154
Mojtaba Hosseini Avatar answered Oct 05 '22 13:10

Mojtaba Hosseini