davidgyoung
davidgyoung

Reputation: 64906

Xcode indentation settings for Swift vs. Objective C

I have a project with a large codebase, where newer modules are being added in Swift 3, but most of the code is in Objective C. Like many projects, our Swift style uses 2 spaces for indentation. The legacy Objective C codebase, however, uses 4 spaces.

Is there any way in Xcode 8+ to configure indentation on a per file type basis? If not, is there a better alternative to:

  1. Converting all Objective C files to use two spaces.
  2. Impose the Objective C 4 space style on Swift code due to Xcode limitations.

Both of the above seem like bad ideas, but without Xcode support for per file type configuration, there seems to be no other way.

Upvotes: 2

Views: 2316

Answers (1)

Zac Kwan
Zac Kwan

Reputation: 5747

To answer your question of:

Is there any way in Xcode 8+ to configure indentation on a per file type basis?

Yes, there is. On the File Inspector of each file, you can set the Indent type to Spaces or Tab and also the number of spaces.

I have attached the screenshot here: enter image description here

You can select multiple file and update the settings at the same time. The settings here will overwrite what you have set in the Preferences > Text Editing > Indentation.

Upvotes: 8

Related Questions