Having a codebase that is managed, structured, clean and scalable and will be very helpful as your codebase grows and features keeps on getting added in your application. So, in this we are going to setup our iOS project following Clean Code Architecture using RxSwift and we’ll be using Swinject for dependency injection.
So, let get on with it.
1. First create a new Xcode project. We are going to use Swift Package Manager to add libraries in our project.
We are going to add these libraries in our project.
We all use libraries in our projects for faster development of applications. Here are some of the libraries that I use in most of my projects.
Almost all of the apps developed today requests data from server and loads it in the app. If you love to use RxSwift in your apps then RxAlamofire is must to perform network requests. It makes your network requests reactive.
RxSwift is my Go-to library for writing business logic layer in any application I write. It makes it so much easier to manipulate responses obtained from server in whichever way…
We’ve all been there. We all know how frustrating it is when it comes to uploading our app to TestFlight. A lot of next and proceed buttons to tap till it successfully uploads to the TestFlight.
Using fastlane, we can skip all that hassles and can push our build to TestFlight with just one line of code i.e.
bundle exec fastlane beta
That would save u a lot of time in the long run. So, for the above code to work firstly we have to do some setup in our project. Let’s get on it then.
Segregating the features in our application is very fruitful for maintaining the application as our application keeps on growing. It helps us in rapid development of new features.
Note: We are going to be using cocoapods for creating modules.
When we are developing our apps we have one backend base URL for testing purpose and another one when pushing the app in live environment.
If you have been manually managing this by commenting out the testing phase base URL uncommenting the live base URL every time you archive and push your app to production, you know how much of a hassle it is. Sometimes you may even forget to do that and push the app pointed to test URL.
If this has happened to you before and you want to avoid such mistakes then here is a solution for…
In this tutorial we are going to implement push notification in our iOS app using firebase.
For this tutorial, we are going to need:
Create a new Xcode project and integrate cocoapods in it. In Podfile, add:
Run pod install and build the project.
Go to Signing & Capabilities in project and add capability named Push Notifications.
In AppDelegate, import Firebase and inside didFinishLaunchingWithOptions function, add:
Create a new project in https://console.firebase.google.com/ for your app. Add an iOS app in that…
In our iOS apps, alerts are used in various screens of the app for notifying users for various cases that occurs in app like success, error, information etc.
So, we all know how to create an alert. It is as follows:
So, if you use this type of simple alerts in your app in most places with varying title and description. We can move forward two ways instead of creating alert in every ViewController.
There may come a time we need to implement contact picker in our application. Users may have more than one phone number saved under a contact name. So, users should be able to choose one from the saved numbers.
Let’s get to coding.
That’s it. Now you can use contact picker in your app as desired.
Don’t know about you devs but I like my network responses pretty printed. This is because I’m picky about these things and also it helps me debug if my application behaves not the way i intended to.
What we’re trying to achieve:
Let’s dive into it.
When we make a network request using URLSession, we get Data from server response. So let’s create extensions of Data and Dictionary.
Now in your APIService class (from where you perform network requests), print the obtained response as: (line no. 18)
What we’ve done is:
Most of the mobile applications basically function by fetching data from the server and makes requests to the server based on the user action performed.
So, in our application we have a NetworkService or ApiService class that handles most of the network related works i.e. GET and POST requests.
For example, we have obtain following json data from the url:
So, for that we firstly create a new class named APIService.swift:
The above shown gist has the necessary generic methods to handle GET and POST requests.
Now comes the part where we perform network requests.