Image for post
Image for post

Greetings. 🙏

In today’s app development, we do a lot of stuff with APIs AKA Network calls in the application. We normally do the network calls with Apple’s `URLSessions` or other third party libraries like `Alamofire`. In this post, we are going to see how we can abstract the networking layer by creating a generic API manager with the help of Apple’s Combine Framework.

Pre-requisites: Basic understanding of Combine. Knowledge on Publishers, Subscribers, Operators. Refer this

Let’s get started…🏁

For this article, I’m going to fetch user details using randomuser.me API. This is a simple project which just does a data task, fetch user details and display it in a list. …


Image for post
Image for post
Typical Home Screen Quick Actions

Home Screen Quick Actions are introduced in iOS 12. A shortcut buttons which navigates the user to a specific place in the application. Nowadays many apps are coming with this Quick Actions. In this post, we are going to learn how can we implement the “Home Screen Quick Actions” in SwiftUI App Life Cycle (2020).

Let’s Start

Types of Quick Actions

  1. Static
  2. Dynamic

Create Static Quick Actions

Static quick actions are defined on the build time. Static actions are never changing actions. It is defined in the project’s Info.plist file.

Right-click on Info.plist file → Open As → Source Code. Then, add below lines.

info.plist

As you can see UIApplicationShortcutItems is used to add the static quick shortcut buttons. This is an array of a dictionary. In each dictionary UIApplicationShortcutItemType and UIApplicationShortcutItemTitle are mandatory keys. …


Image for post
Image for post

New iPadOS 14 has this beautiful layout. In this structure, we can split the iPad screen into three Views.

  1. SidebarView
  2. PrimaryView
  3. DetailView

Previously, we are having the Master and Detail View concept. But in this article, we are going to learn how to develop a three-sectioned iPad layout design in SwiftUI 2.0.

Pre-requisite:

This complete project was developed in Xcode-12.0.1. Make sure you are using Xcode 12 or above.

Overview:

I have listed down some Movies and some TV shows to demonstrate the layout. The first view will contain the main menus of the Application.

In my case, I have Movies and TV…


Today's life mobile cameras are playing a very important role in almost every application. Some examples are Updating profile Pics, Sending Photos, Scanning PDFs, etc. So, for an iOS developer, it is very basic to know how to integrate the camera with an iOS app.

Let’s learn how to integrate Camera in an iOS app.

As there is no native SwiftUI method to open Camera, we are going to use UIKit’s UIImagePickerController and wraps it in UIViewControllerRepresentable struct. Then we can use that struct as SwiftUI view.

Note: Camera only works on a real iOS device.

The process has 4…


Image for post
Image for post

We know that every element in SwiftUI is a View. A modifier is used to change the behaviour of the View. Let’s see this with an example,

Button(action: {
print("Submit clicked")
}){
Text("Submit")
.foregroundColor(.white)
.padding(.horizontal, 30)
.padding(.vertical)
.background(Color.red)
.clipShape(Capsule())
.shadow(color: .red, radius: 10, x: 0, y: 5)
}

We have created a button view and it looks like below,


Tip 1:

Always apply .background() after setting .padding()

Here is an example,

Text("Hello")
.background(Color.blue)
.padding(.horizontal, 40)
.padding(.vertical, 20)

For the above snippet, I’ll get something like below

Image for post
Image for post

Same thing if we apply the tip,

Text("Hello")
.padding(.horizontal, 40)
.padding(.vertical, 20)
.background(Color.blue)

we will get,


Image for post
Image for post
share sheet — iOS

On many scenarios, We have used this share sheets in iPhone. Mostly,

  1. Airdrop something to a nearby person.
  2. Send something via iMessage, Whatsapp or Mail.

How to achieve this in SwiftUI? Let’s learn this 👨‍💻

To create a Share sheet we have to do 3 simple steps,

  1. Get the data you want to share
  2. Create a UIActivityViewController object and attach the data with this
  3. Present the UIActivityViewController

Step 1:

guard let data = URL(string: “https://www.zoho.com") else { return }

Here, we have created an URL. This is the data we are going to share using the share sheet.

Step 2:

let av = UIActivityViewController(activityItems: [data], applicationActivities…


QR codes -> Quick Response codes are used to store a text in an image. Normally we have seen this kinda codes in shopping malls, online stores, and many more places. Nowadays, we are scanning some weird square box shape in mobile camera for UPI transactions in many places. Those box shapes are nothing but this QR codes only.

Let’s look at how we can create our own QR codes in iOS, SwiftUI.

In order to create QR code, we need to follow below steps,

  1. Get the Text(String) which you want to create as a QR code
  2. Convert the Text into…


We all have the Take screenshot on Test failure in our framework. But sometimes the screenshot will not help us. We are like OMG why this test is failing state.

For those, this post will really helpful. We can record the whole test execution as a video with low resolution.

Prerequisite: Please install ffmpeg (brew install FFmpeg)

Start Recording the video

driver.startRecordingScreen();

the above command will simply start the recording with default record options. We can add video quality, fps, time limit, video type, etc.,

Below is the sample code for adding medium video quality for iOS

//iOS
driver.startRecordingScreen(new IOSStartScreenRecordingOptions().withVideoQuality(IOSStartScreenRecordingOptions.VideoQuality.MEDIUM));
//Andoid
driver.startRecordingScreen(new AndroidStartScreenRecordingOptions()....);

Stop Recording the video

String base64output =…

About

Jeeva Tamilselvan

Automation QA Engineer by profession. Learning iOS Development.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store