π¨ Xcode Reimagined with Emojis
πππ€π©π΅ππππ
Ever since Mountain Lion Apple added full support for emojis in terminal.
Nobody cared.
When Swift came out it had a full native support for emojis anywhere (incβ type names, function names etc.).
3 people cared.
Apple file system fully supports emojis for file/folder names since Lion (or was it Mavericks?).
Maybe 10 people care.
But we should care! Emojis are probably the easiest symbols to spot in a blob of characters, and we can use them to sort, tag, identify and spot everything in our project lightning fast!
First is the project structure. The more our project evolves we start to have tons of folders/groups in the project navigator and pretty quickly it starts to get very difficult to tell whatβs where. Adding emojis to the groupβs names pretty much solves this issue. The best way Iβve found to name groups is with the βmo-nameβ template, where the name starts with a representing emoji, then a space followed by the actual name.
Note that the emoji itself can either be a logically objective representation of that group, or a completely subjective emotionally motivated pick (after all, most emojis are pretty extreme emotional representationsβ¦). This way all the names are still perfectly aligned with the project navigator hierarchy, and those who are still not used to emoji-driven-navigation can just ignore them and comfortably read the plain boring names for ten minutes until they find their file.
The second place we should fill up with emojis is our log. The log is a bunch of endless text where we sometimes spend almost a full minute just trying to find the place in it that has the JSON response print we are looking forβ¦
We can divide the emoji printing into two main types β constant ones and dynamic ones.
Constant emojis are those that repeat themselves for a certain kind of log. For example, we can have a global function that prints the current function with a special π© emoji so we can spot such a print from miles away:
func printFunc(val: Any = #function) {
print("π© \(val)")
}
Another use can be a certain emoji that represents an error log, and can be also be printed through a special global function:
func logError(val: Any,
filename: StaticString = #file,
line: UInt = #line,
funcname: StaticString = #function) {
logError("βοΈ\(funcname)(..) π \(val) [\(filename.className()):\(line)]")
}
Dynamic emojis can represent specific events that happen or kind of data. For example, a single server request & response can be logged like this:
π‘ POST https://my.server.com/api/v1/Login
π¦ ["billingType": 1, "user": "mickJagg1", "ISOCode": "il"]
π Data received: 3.4kb
β
Login β‘ π 200 | β± 2159 ms πβοΈ
Here we have the emoji in the first line representing a new request sent to the server. The emoji tells us what happened, so we can make the log extremely concise, showing only the request info itself, without any extra explanatory text.
Next, we print the params sent in the request body (represented by π¦-package emoji).
When we get our response, we can see itβs size (if we feel that not every other developer would immediately recognize the watermelon as βamount of dataβ we can add the small label to detail it; although itβs pretty clear that this is what the watermelon emoji representsβ¦).
The last line shows some emojis that are also part of the information on their own: the green checkmark tells us that the request went well, then we have our response code, and request time in ms. When the request takes over a certain delta to return, we add the πβοΈ emojis to warn that the request was probably too slow to process.
We can do so much more like printing headers (π), token (π) or the entire response data (π¬), and this is only for our APIs! The β οΈ is the limit!
Here is an example from one of my projects for launching an app:
2016/08/14 09:02:17:346 π APP LAUNCH: 14/08/2016, 9:02 AM
2016/08/14 09:02:17:418 ππ» Running on DEBUG mode
2016/08/14 09:02:17:419 βοΈ Not using Analytics SDK
2016/08/14 09:02:17:428 πͺ Validation: FRESH (showing login)
2016/08/14 09:02:17:477 π© registerVoipNotifications() [AppDelegate]
2016/08/14 09:02:17:479 π First use: setting defaults
2016/08/14 09:02:18:103 π© pushRegistry(_:didUpdatePushCredentials:forType:) [AppDelegate]
2016/08/14 09:02:18:107 π Did Update VoIP Push Credentials [AppDelegate]
See how easy and nice it is to try to understand what is happening here? Try comparing it to any other standard log that would print similar dataβ¦
Type βem
It is true that typing an emoji is not as easy as typing ASCII (although this thing existsβ¦), but macOS makes it pretty easy to get your emoji:
Press CMD+Ctrl+Space to open the emoji popup, than just start typing to search for the emoji you are looking for. Single-click an emoji to type it. You can use the same approach for any special character; type βsubsβ for example for all the subscript characters available.
Pro Tip πͺ
If you are using Wunderlist, you can begin your list title with an emoji and that emoji will become the icon for that list!