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
.
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.
In this article, we will learn what is OptionSet
in Swift and how to create your own custom OptionSet
.
OptionSet
is a protocol to represent bitset types, where individual bits represent members of a set.OptionSet
is similar to enum
, but they are designed to work as a set so we can use multiple values at the same time.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…
SwiftPM
is a tool for managing the distribution of Swift code just like CocoaPods
and Carthage
.SwiftPM
is included in Swift 3.0
and above enables us to manage Swift dependencies.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.
Build Settings
of your project.Any iOS Simulator SDK
with value arm64
inside Excluded…
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.CocoaPods
from your project, make sure all your dependencies are compatible with SwiftPM
.spmready
by Humi to check If all your dependencies are ready to migrate to SwiftPM
or not.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.
Apple’s official tool to simulate network connections on macOS for testing purposes is the Network Link Conditioner.
Recently, I’ve designed one of the screens of my project using the Sketch application. I’ve given a shadow property to the element with blur
and spread
.
But when I try to replicate the same shadow effect in the iOS application, it doesn’t quite work. That’s because the spread
property does not exist in the CALayer
class of the CoreAnimation
framework. Also, blur
and shadowRadius
don't produce the same effect as the Sketch app.
The following are the results of setting a shadow offset of (10, 10) and a blur radius of 10 with spread value of 3 in Sketch and…
During its annual September 15 hardware event on Tuesday, Apple announced the Apple Watch Series 6, Apple Watch SE, iPad Air, and iPad 8th generation. As rumoured before, Apple didn’t debut the iPhone 12 lineup at its September 15 event.
In addition to the hardware products, the company also announced a new subscription service, called Apple Fitness+, as well as Apple One service bundles to help keep things simple — and keep you subscribing.
In my previous article, we have learned how to integrate SwiftLint
into the Project. In this article, we’ll learn how to disable rules. Rules can be disabled either at the project level or source level.
If you don’t want to use the specific rule(s) for your project then you can disable those rules completely by configuring .swiftlint.yml
file as below:
# rule identifiers turned on by default to exclude from running
disabled_rules:
- trailing_whitespace
- force_cast
- force_unwrapping
- force_try
It is also possible to skip some files by configuring .swiftlint.yml
file as below:
excluded: - file1 - file2 …
SwiftLint is a tool to enforce Swift style and conventions, loosely based on GitHub's Swift Style Guide.