Image for post
Image for post
Photo by Maxwell Nelson on Unsplash

Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.

Everyone knows that Swift is an open-source language from Apple and is available on macOS machines. Some of you might even know that Swift can be compiled on iPadOS.

But did you know that Swift is also available on Ubuntu? If yes, have you ever tried it?

Let’s try this out here—this post will walk you through compiling a Swift file on Ubuntu.

Getting Ubuntu

If you have an Ubuntu machine available, you can skip to the Downloading Swift section.

Otherwise, don’t worry. I can help you get an Ubuntu VM on your macOS or Windows workstation. We’ll use a product called Multipass from Ubuntu to instantly create Ubuntu VMs on your existing machine(s). …

Creating custom variables & looking into some of the predefined ones in Xcode

Image for post
Image for post

According to Wikipedia, an Environment Variable is a dynamic-named value that can affect the way running processes will behave on a computer. They are part of the environment in which a process runs.

It also gives an example, that the process can query for the value of an Environment Variable named ‘TEMP’ to discover the location to store temporary files.

When you are trying to run a server this example makes good sense. Another example will be of getting the port on which the server should run.

Apart from this, one of the most important use of Environment Variables is to pass secret configurations to the process at run time instead of hardcoding it while building and committing it to your repository. This includes but not limited to setting API Keys for a dependency, password or other forms of credentials to authenticate to another service. …

In this post we’ll look how Protocols and Dependency Injection can help us in writing pure testable code in Swift.

Purity of the class or API is determined by the dependency it has. For example, if you have an API to find sum of two numbers that accepts those two numbers as parameter, it is pure. There is no dependency to that API.

But if you have an API that adds a number to a global variable and accepts only one argument, it is not pure. Its response depends on the value of global variable and the arguments. …


Lazim Mohammed

Swift Developer, Avid Learner, Tech Lover, Design Enthusiast!

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