It may not be very popular within the development communities, but yes, like many (if not all) IDEs, Xcode also allows you to customize the theme.
What is a Theme
Speaking specifically for Xcode, a theme is a .xccolortheme
file that is internally XML-formatted and uses plist
to define the values for each key.
I show you an example below.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.65098 0.698039 0.752941 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>FiraCode-Medium - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.65098 0.698039 0.752941 1</string>
<key>DVTConsoleDebuggerOutputTextFont</key>
<string>FiraCode-Medium - 11.0</string>
<!--Many many more key-values...-->
</dict>
</plist>
We could manually create this file and assign each value, of course, it is possible, tedious and fortunately, Xcode makes it just a little easier for us.
Themes Screen
In Xcode we can select one from a small list of its built-in themes, then I will show you how to access this screen
- We open Xcode
- In the menu bar we click on Xcode
-
We click on Preferences
💡 We can replace step 2 and 3 using the shortcut ⌘ + ,
- (1) From the options at the top we select Themes.
-
(2) On your left side you can see the built-in themes of Xcode
💡 If you create a new theme, it will also appear in this list.
-
(3) To the right of the themes you can see each type of text that is displayed in the source editor
💡 You can even modify the built-in themes if you wish..
- (4) Since Xcode also has a console view, it includes its texts and you can see them by selecting this option.
- (5) Here you can change the font style, size, and color, as well as the space and general colors of both the text and the background, selection, cursor, etc.
Creating a new theme
- We click on the + button.
- A dropdown will open that will allow us to create a theme based on a template, the template is based on the built-in themes that Xcode has, so if you already like one, let’s start with that one.
- We assign a new name to our theme
- We edit each different type of text from our source editor and console to our liking
Using an existing theme
As you could see in the previous point, we can create our themes, and just as we can create them, there are people in the community who help us by sharing theirs.
-
To add a new theme first of all we need the theme file.
👀 do you remember the file type? - that’s right!, this must be a
.xccolortheme
-
Open Finder
- In the Finder menu bar click on Go
-
Click on Go to folder
💡 You can replace step 3 and 4 using the shortcut ⌘ + ⇧ + G
-
We headed to the next path
~/Library/Developer/Xcode/UserData/FontAndColorThemes/
⚠️ If the UserData and/or FontAndColorThemes folders do not exist, you can create them manually without any problem
- Drag and drop the theme to this folder.
-
Open Xcode and select your new theme.
⚠️ If you had Xcode open, you may need to restart it to see the theme changes
And that’s all you need to do 👍
Bonus (One Dark Theme)
If you made it this far, let me share a theme that I like, to begin with, I am from that group that prefers dark themes.
Atom has a very popular theme within the community, this theme is not from my source but it is practically the one shared by Bojan Dimovski.
This is how our theme will look and you can download it from here
Inside you will find its series of installation steps, this theme uses Fira Code as its main font so you will have to download it too.
How to install (easily)
- Open your terminal.
-
Go to the path where you want to download the repo (ex. Desktop).
cd Desktop
-
Clone the repository.
git clone https://github.com/SwiftyJourney/OneDarkTheme.git
-
Go into the downloaded repo folder.
cd OneDarkTheme
-
Run the package.
swift run
🥳 You will not need to manually download the font
-
(Optional) Delete the repository folder (it is not needed anymore).
cd .. rm -rf OneDarkTheme
- Don’t forget to apply the theme in Xcode.
- Enjoy it (or customize it too).
Conclusion
Xcode topics may not be a very broad topic of conversation, but there are quite a few good ones in the community, normally Xcode would be your day-to-day IDE whether this is your hobby or part of the work day, then what better power than improve its visualization for you.
I hope this article helps you, I’ll appreciate it if you can share it and #HappyCoding👨💻.