Reducing Code Duplication in Swift using fundamentals of programming

Duplication, as the name suggests, is something that exists more than once. The same goes for code duplication. It's code that exists many times in the same codebase. An increase in the codebase, a subsequent rise in code duplication - is this what's happening with you? If yes, then: Have you ever thought about why this happens? The code duplication subsequently increases with time as many developers work simultaneously on similar functionalities in the codebase. Is it a good programming practice? No, because coding works on a fundamental principle called DRY, i.e., Don't Repeat Yourself! We must follow the

How to optimise localization in iOS Swift App?

It's never been as easy as it is now to launch into global markets via mobile apps. You must be wondering why I wrote this blog because we can easily support varying locales to understand and be usable by all users, right? Let's read why. Earlier, providing L10n (localization) was just possible natively by integrating .strings, .stringsdict and .plist files in Xcode. This approach had various drawbacks such as: App's language would be set to the device's language by default instead of choosing the preferred language. There was no out-of-the-box support for .json. However, JSON support could be accomplished natively

Optimizing data retrieval using Realm Swift query

This article gives insights on Realm Extension Functions, through which time taken for a filter on the database is drastically reduced.

Customize native alert view in iOS

Nearly every project/app needs an alert popup. It is an essential UI element to: Provide information/warning to the user before performing any actionHandle user interaction to perform any actionNotify the user on completion of an actionThe default alert popup is very simplistic. Nowadays, we see a unique style and attractive UI in popups rather than showing a classic native/default one. What do you show in a popup? Title, message, image, and action buttons. Isn't it? But if you want to make your custom alert popup, it requires a lot of effort as you need to manage UI

Dynamic UIButton Font Size in Swift

In today's fast-paced world, everyone wants the comfort of preferences. With it comes the preference to personalize their devices too. This can be in the form of dark/light mode, wallpaper, ringtone. So do they get the flexibility of adjusting font size suitable to their eyes too? Yes, they get it! Dynamic font sizes make an app readable without much effort. We can implement dynamic font sizes using (Attributes Inspector → Font → Text Styles). Same illustrated below: a. Dynamic Font Setting for UILabel Note: Don't forget to select the Dynamic Type checkmark as shown in the last step above. Without it,

Environment setup to manage different app name, icon and endpoint using Xcode Configurations in iOS Swift Language

As a Developer, you have many challenges while you are working with many environments and endpoint in the same project. Without environment setup, you have to set the endpoint and certificate every time for a different environment. If we Configure Xcode for the different environment, It takes care of all endpoint, certificate and bundle ids. so the user can test all beta, dev and live app on the same device. So, let's start with creating Endpoint Endpoint Configuration The first thing that you have to do is prepare Xcode configurations for the environment you want to use. In this post,

Integrate Fastlane with iOS App for Build Automation

As we all know uploading the iOS App on the App Store is a very long procedure. Some developer gets stuck at the certain point and fails to upload the app. So let's make the procedure very short of uploading the app with Fastlane Tool. Fastlane provides the easiest way to build and release the mobile apps. It handles the time-consuming task for you, so you don't have to waste your development time. Through Fastlane you can automate the process of taking the screenshot of the mobile app screen, building the app for the different environment such as Adhoc, Development,

Use of Auto Layout in iOS

What is Auto Layout? Auto Layout is a constraint-based layout system. It was introduced with Xcode 6 Beta. It allows developer to create an adaptive UI for the apps that responds appropriately to changes in screen size and device orientation. Auto Layout dynamically calculates the dimensions and position of all the views in your view hierarchy, based on constraints placed on those views. Why Auto Layout? Today we have lots of variants available of iPhone and iPad in size in market. So, the user have different iPhone or iPad as per their choice. But according to the developer when he

Face ID Authentication in iOS11 Swift Language

Apple released most interesting feature Facial recognition with iPhone X. Face ID is a new revolution in recognition. It is a powerful and secure authentication system that’s more convenient, faster and easy than Touch ID. Face ID is biometric authentication. Biometrics technology is mainly used for identification and access control. Touch ID recognition is also biometric authentication. Face ID uses LocalAuthentication Framework for authentication and Touch ID uses the same framework for authentication. This framework provides facilities for requesting authentication from users. It provides the interface for evaluating authentication policies and access controls and managing credentials with LAContext. LAContext

Make Indicator always visible for UIScrollView in iOS Swift Language

Naturally, Indicator of ScrollView is visible when the content view of ScrollView is longer than ScrollView height and user drag on Screen. As we all know It is a default functionality, we can't make it always visible directly. Using flashScrollIndicators() method we can make it visible. Example override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(true) scrollView.flashScrollIndicators() } But indicator only appears for some time after viewDidAppear method call and disappear again. Indicator only to reappear when the user touches the screen. To show indicator continuously without touching screen you can add flashScrollIndicators() method in Timer. Timers work in continuously with