1) Install Xcode extensions

a. nef extension

  • The installation guide will be available on https://github.com/bow-swift/nef-plugin

b. Alignment for Xcode

Once you install the extensions you have to enable them.

  • Navigate to System Preferences ➞ Extension ➞ Xcode Source Editor
  • Select all the extension that you are keen to use
  • Relaunch Xcode
Xcode Extension

2) Show Line Numbers and Code folding ribbon


Swift Collections — Deque | OrderedSet | OrderedDictionary
  • Swift Collections, a new open-source package focused on extending the set of available Swift data structures.
  • The package currently provides the implementations of the most frequently requested data structures: Deque, OrderedSet, and OrderedDictionary.

1) Deque

  • You can use the prepend method to insert a new element at the beginning and append to insert an element at the end of a deque.
  • Similarly, you can use popFirst and popLast to pop…


It’s a beautiful spring morning for an AppleEvent — Spring Loaded

On Tuesday, April 20, Apple ended their first event of 2021 by streaming a virtual keynote called “Spring Loaded” held at its campus in Cupertino, California.

During the event, Apple unveiled a new podcast subscription service and a bunch of new hardware products including the much-awaited AirTags, the Bluetooth tracker.

If you missed the event, here’s what you need to know.

Apple Podcasts Subscriptions:


Sorting on collection is very easy for single criteria. Swift already has a built-in function for that called sorted (Its in-place variant, called sort). But, sometimes we need to sort the collection by multiple properties or criteria.

To understand this, let’s create a simple struct for Student with the roll number, name, address, and age property.

In order to sort the student list by address we can use the following code:

Student.students.sorted {
return $0.address < $1.address
}

But what happens when the address value will be the same? That’s where multiple criteria sorting comes into the picture.

What is the meaning of multiple criteria sorting?

Multiple…


In Swift (or most of the programming language), the default method for sorting an array uses lexicographic order. That means string Foo12 does come before the string Foo2.

Example 1 (Lexical Sort):

Lexical Sorting

In most cases, we perform lexical sorting on our array. But there might be a scenario where we need to use natural sorting for a better look on for end-user. (eg. Sorting File Names). In the natural soring order, the string Foo12 comes after the string Foo2.

We can achieve natural sorting in swift using the localizedStandardCompare(_:) method from the Foundation framework.

Example 2 (Natural Sort):


Swift — OptionSet Type

In this article, we will learn what is OptionSet in Swift and how to create your own custom OptionSet.

What is OptionSet?

  • OptionSet is similar to enum, but they are designed to work as a set so we can use multiple values at the same time.
  • As OptionSet confirms to SetAlgebra protocol, we can use methods like intersection, union, contains, isDisjoint and several other methods that you might have used on Set.

As a matter of fact, Swift’s OptionSet protocol is the bridged version of…


Easily turn your code into a Swift Package

Photo by Emile Guillemot on Unsplash

What is Swift Package Manager (aka SwiftPM or SPM)?

  • It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
  • The SwiftPM is included in Swift 3.0 and above enables us to manage Swift dependencies.
  • With the release of Swift 5 and Xcode 11, SwiftPM support added within Xcode itself.

Here’s a step by step guide for creating your first swift package in Xcode.


Recently, I have updated my Xcode to the latest version (Version 12.2 (12B45b), and my project running fine for real devices. But when I try to run on iOS Simulator I am getting the following error.

building for iOS Simulator, but linking in object file built for iOS, file for architecture arm64

To solve this problem we have to exclude arm64 for simulator architecture both from your project and the pod target.

Solution using Exclude Architectures

Solution for Project Target

  • Navigate to Build Settings of your project.
  • Add Any iOS Simulator SDK with value arm64 inside Excluded…


Migrate your Swift project from CocoaPods to SPM
  • We’re using Cocoapods for several years, but Swift Package Manager (SPM) is new standard dependency manager which included in Swift 3.0 and above. If you are the one who wants to adopt SwiftPM in your swift project, this is how to do it right.
  • Before removing CocoaPods from your project, make sure all your dependencies are compatible with SwiftPM.
  • I’ve found one small tool spmready by Humi to check If all your dependencies are ready to migrate to SwiftPM or not.
  • If all your libraries are not compatible with SPM , then either you go ahead with CocoaPods + SPM


While developing mobile apps that require internet connectivity, it's significant to handle poor network conditions. Because mobile app users will likely to have a much slower network than we use while developing.

As a developer, you didn’t want to throw away your invaluable time looking for a location with a poor network to test the app. So there are some ways to simulate poor network conditions during development.

Simulate Poor Network on iOS Simulator

Apple’s official tool to simulate network connections on macOS for testing purposes is the Network Link Conditioner.

1) Steps to install Network Link Conditioner

Milan Panchal

iOS Team Lead — Mobile App Developer ǁ Swift ǁ Objective-C ǁ Lifelong Learner ǁ Blogger https://milanpanchal.github.io/

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