Announcing our Experimental Linter Tool for Firebase on iOS

Ever spend an hour wondering why Remote Config wasn’t working, only to realize that you forgot to call activateFetched? Or didn’t read a Dynamic Link because you forgot to implement the application:continue:restorationHandler method? Well, now there’s a tool to help stop those mistakes before they happen!

SwiftLint is a great open source tool that makes it easier for you to follow Swift style and conventions. It also helps with identifying possible errors early by highlighting problematic usage. You can run SwiftLint on your Xcode project to see all the style guide exceptions on the lines where they occur, and fix them quickly. I found it was a great help when I migrated my code from Objective-c to Swift.

In the spirit of making SwiftLint even more useful for Firebase developers, we’ve added some experimental new Firebase rules into SwiftLint. These rules will display warnings on common mistakes that might lead to errors when using the Firebase SDK.

How to use

Currently we are hosting the rules on our fork in a firebase_rules branch. Our pre-release binary holds the Firebase rules. You simply download the .pkg file and double click to install. You can also build the binary from the source.

Since the rules are opt-in, you’ll need to add a .swiftlint.yml file in the same folder as your Swift source files, containing the following text:

 - firebase_config_activate
 - firebase_config_defaults
 - firebase_config_fetch
 - firebase_core
 - firebase_dynamiclinks_customschemeURL
 - firebase_dynamiclinks_schemeURL
 - firebase_dynamiclinks_universallink
 - firebase_invites

Then, just run SwiftLint on your project like normal.

If you’re interested in how we put the rules together, you can read our post with all the development details.

We’d love for you to give it a try and send us feedback on Twitter with #FirebaseLinter. You can also ask questions on StackOverflow using the firebase and swiftlint tags together.

Happy coding!