Syntax highlighting for Swift in BBEdit and TextWrangler

Big thanks to Curt Clifton (https://github.com/curtclifton – his bio indicates that he’s with the Omni Group!) for creating this codeless Language Module for Swift that can be used in BBEdit and in TextWrangler.

A BBEdit Codeless Language Module for Swift

Curt indicates there are some limitations to codeless language modules:

Keyword, comment, and string highlighting work. Top-level classes, structs, enums, functions, and extensions are indexed and can be folded. Because of limitations in the matching power of codeless language modules, nested declarations are not indexed and are not fold-able.

However, it works great if you want to do some Average Joe coding in Swift in TextWrangler or just see your .swift files highlighted outside of Xcode.

Installation is super easy:

BBEdit

  1. Copy the file swift.plist to ~/Library/Application Support/BBEdit/Language Modules. You may have to create the Langauge Modules folder if it doesn’t exist.
  2. Quit and relaunch BBEdit.

…and for TextWrangler it’s just as simple:

TextWrangler

  1. Copy the file swift.plist to ~/Library/Application Support/TextWrangler/Language Modules. You may have to create the Langauge Modules folder if it doesn’t exist.
  2. Quit and relaunch TextWrangler.

Smoother transitions when showing a View Controller with a UINavigationBar in Swift

Here’s the scenario. You want to display a modal view controller without a navigation bar, and then from that view controller you want to navigate to another view controller that displays a navigation bar.

First to get things set up, in the Storyboard we set up the view controller that would be displayed modally. We create a view controller, perform the Editor -> Embed in -> Navigation Controller. Then, in the viewWillAppear method, we hide the navigation bar programmatically.

It turns out that there are two ways to do this and, at least in my case, one way turned out to be better than the other. The first way I tried worked, but the animation for the transition from one view controller to the next looked a little odd.

The first way is the more obvious of the two, because you can simply just set the hidden property of the navigationBar like in the following example:

self.navigationController?.navigationBar.hidden = true

There is also another way to do the hiding and showing of the UINavigationBar, and the second way is do do it via the UINavigationController, as in the second example:

self.navigationController?.setNavigationBarHidden(true, animated: true)

There are two advantages to doing it the second way. First, because you get a method to hide and show the navigation bar, you get the additional animated parameter that you can set.

The second advantage is that when you use it in this way with the animated parameter set to true, iOS performs a slightly more smooth transition.

Your mileage may vary, so try both ways and see which you personally like best.