The Top 5 iOS Libraries and Add-Ons Every Beginner Swift Developer Should Know
Tags: Ios Developer, Cocoapods, Xcode, Ios Development, Swift

Without further ado, let’s jump right into my favourite iOS 14 compatible libraries that made my life as a part-time iOS developer a lot easier and added significant value to the end product.

Charts

Complexity to set up: medium

In case you need to visualise any kind of statistical or historical data within your app, do not code it yourself. Instead, you can use the Charts library. It offers an easy and intuitive way to generate various charts and allows to format them in all kinds of ways. The following chart types are currently supported: line charts, bar charts, scatter charts, candle stick charts, bubble charts and radar charts. Certain chart types can also be combined with each other (e.g. line chart as an overlay to a bar chart).

Official Charts logo taken from GitHub

After you have installed and imported the library in your Xcode project, I suggest the following basic steps:

Raw data: It is good enough, to prepare the data in such a way that you can pass an array of objects (either classes or structs) into Charts. Each object within the array must contain at least the information you want to display in the chart (e.g. date and number in case you want to show historic data within a bar chart). Add chart to GUI: Add a UIView to you ViewController and let it inherit from the type of chart you need, e.g. a CombinedChartView. Connect the view to your code. Populate chart: Create a helper function that receives the chart view from step two and the raw data from step one. Within this helper function, you can then conveniently assign data points from the array to the various components of the chart like the x-axis and y-axis.

Constraint: The library currently does not work with SwiftUI out-of-the-box but there is a wrapper solution for this explained in this great article.

Bart chart, line chart and pie chart example of Charts iOS library in this fitness tracker

MongoDB Realm

Complexity to set up: high

Realm is an offline-first database for iOS (and many other platforms) and a must-have library in case you are building cross-platform applications that require seamless data storage and synchronisation. Realm has been around for a few years and has recently been integrated into the MongoDB platform. For me personally it solves the following key problems:

Local mobile database: Realm is a convenient way to store and retrieve data locally on your users’ devices. It is therefore a great replacement for Apple’s CoreData. They advertise it as a mobile database and that describes it pretty well. I also find it easier to use than platforms such as Firebase. It is worth noting that you do not necessarily need to use the online storage functionality to use Realm. The mobile database is open source and free of charge.

Realm is a convenient way to store and retrieve data locally on your users’ devices. It is therefore a great replacement for Apple’s CoreData. They advertise it as a mobile database and that describes it pretty well. I also find it easier to use than platforms such as Firebase. It is worth noting that you do not necessarily need to use the online storage functionality to use Realm. The mobile database is open source and free of charge. Online data storage: The most powerful feature is obviously the possibility to synchronise every user’s local data across devises with the MongoDB cloud database. From a developer perspective, handling the data is essentially the same as working with local data. Bidirectional data synchronisation is happening in the background and you do not need to worry about it as a developer. The biggest challenge for me was that there is no built-in switch that conveniently switches over from the local to the cloud realm database once a user signs-up with your app. This logic must be implemented by the developer.

The most powerful feature is obviously the possibility to synchronise every user’s local data across devises with the MongoDB cloud database. From a developer perspective, handling the data is essentially the same as working with local data. Bidirectional data synchronisation is happening in the background and you do not need to worry about it as a developer. The biggest challenge for me was that there is no built-in switch that conveniently switches over from the local to the cloud realm database once a user signs-up with your app. This logic must be implemented by the developer. Cross user analytics: Now that Realm has been acquired by MongoDB, you can use all the great features that MongoDB offers around data analysis. Therefore you are able to do cross-user analytics in a convenient way.

Please note that it will take some time to go through the tutorials, spin up a MongoDB instance and adjust your iOS code accordingly. But once it is working, it is a real game changer for your app.

MongoDB Realm image taken from mongodb.com/realm website

Bond

Complexity to set up: medium

Bond is a reactive binding framework for Swift and a great addition if you are planning to use the MVVM pattern in your app. It is easy to set up and use. In essence, it simplifies the way you wire your UI to the data in your view model.

Let’s dive into an example to give you an idea on how Swift Bond works. The following example has four UI components on the view controller:

restTimerTitle (UILabel)

restTimerSlider (UISlider)

restTimerSwitch (UISwitch)

restTimerTimeLabel (UILabel)

Each UI component is connected to the view model via Bond. This allows the view controller to display data changes from the model and (in case bidirectional synchronisation is needed) vice versa update data in the view model based on changes on the UI.

Swift Bond binding in action for a UILabel, UISwitch, UISlider

The restTimerTimeLabel is observing changes of the formatted duration and then displays it on the UILabel and adds a nice fade transition when the value changes (lines 1 through 5). The restTimerSlider is wired to the restTimerDuration value from the view model bidirectionally (line 6). Therefore any change from the slider directly updates the view model in one single line. The remaining lines 7 to 9 add some formatting based on the data from the view model.

Swift Bond to wire your view model and UI

Firebase

Complexity to set up: medium to high

Official Firebase logo taken from Firebase website

Google’s Firebase framework offers various modules that will make your live as an iOS developer a lot easier. Key features that I find most relevant for beginner iOS developers are:

Authentication: The most relevant feature for me. A great way to add authentication to your app. Firebase supports various ways for users to sign-up with your app such as username / password, Google, Apple, Facebook, Twitter, etc. I personally use Firebase authentication together with MongoDB Realm (see above) which requires some setup (e.g. generating your own JWT token and writing your own Firebase function).

The most relevant feature for me. A great way to add authentication to your app. Firebase supports various ways for users to sign-up with your app such as username / password, Google, Apple, Facebook, Twitter, etc. I personally use Firebase authentication together with MongoDB Realm (see above) which requires some setup (e.g. generating your own JWT token and writing your own Firebase function). Cloud Functions: Cloud Functions is Firebase’s serverless framework to host JavaScript / TypeScript based code. Functions can react on Firebase events or can be triggered via HTTPS requests. I for instance use Cloud Functions to automatically send a welcome message as soon as a user signs-up with my app.

Cloud Functions is Firebase’s serverless framework to host JavaScript / TypeScript based code. Functions can react on Firebase events or can be triggered via HTTPS requests. I for instance use Cloud Functions to automatically send a welcome message as soon as a user signs-up with my app. Storage: You can leverage Firebase to let each app user store personal binary object such as images and videos. The setup is fairly easy and well documented. What a great way to enhance your app by letting users upload and share their images and videos.

You can leverage Firebase to let each app user store personal binary object such as images and videos. The setup is fairly easy and well documented. What a great way to enhance your app by letting users upload and share their images and videos. Crashlytics: You can conveniently track app crashes across your apps and versions with Firebase’s crash reporting solution. Unlike with Apple users do not necessarily opt in to activate the recording of app crashes. You will see when and where in your code crashes have happened.

Of course, there is also the popular Firestore and Realtime Database functionality. Firestore is a NoSQL database that allows you to store user data. I do not use Firestore since I consider MongoDB Realm to be the better solution for this particular task.

I have seen articles where people complain about the performance and scalability of Firebase. This is a problem that at least I cannot relate to. So far, I have experienced Firebase as a very reliable service for the features that I am using.

Hero Transitions

Complexity to set up: low

The Hero library is a quick win that can easily be integrated into your app. It will beautify your app with smooth transitions between view controllers. You can choose between ready-made animations and you can even customise the transitions to create more complex animations.

Official Hero Transitions logo taken from GitHub

IQKeyboardManager

Complexity to set up: low

This is an honorable mention at place six. It might not be a general purpose library like the other ones above but it is a great help when dealing with text inputs in your app. It solves the following two problems very well: