The Blog

How to use SF Symbols in your apps

It’s been a while since Apple announced SF Symbols at WWDC 2019 and I remember how excited everybody was about them. The prospect of having an easy to integrate set of over 1,500 icons that you can display in nine weights sounds very appealing and has helped me prototype my ideas much quicker with good looking icons than ever before. I haven’t heard or seen much content related to SF Symbols since they came out and I realized I hadn’t Read more…

Find and copy Xcode device support files

Every once in a while I run into a situation where I update my iPhone to the latest iOS before I realize I’m still using an older version of Xcode for some projects. I usually realize this when Xcode tells me that it “Could not locate device support files”. I’m sure many folks run into this problem. Luckily, we can fix this by copying the device support files from the new Xcode over to the old Xcode, or by grabbing Read more…

Enforcing code consistency with SwiftLint

If you’re ever amongst a group of developers and want to spark some intense discussion, all you need to do is call out that tabs are better than spaces. Or that indenting code with two spaces is much better than four. Or that the curly bracket after a function definition goes on the next line rather than on the same line as the method name. A lot of us tend to get extremely passionate about our preferred coding styles and Read more…

Calculating the difference in hours between two dates in Swift

Sometimes you need to calculate the difference between two dates in a specific format. For instance, you might need to know the difference between dates in hours. Or maybe you want to find out how many days there are between two dates. One approach for this would be to determine the number of seconds between two dates using timeIntervalSince: let differenceInSeconds = lhs.timeIntervalSince(rhs) You could use this difference in seconds to convert to hours, minutes or any other unit you Read more…

Adding your app’s content to Spotlight

On iOS, you can swipe down on the home screen to access the powerful Spotlight search feature. Users can type queries in Spotlight and it will search through several areas of the system for results. You may have noticed that Spotlight includes iMessage conversations, emails, websites, and more. As an app developer, you can add content from your app to the Spotlight search index so your users can find results that exist in your app through Spotlight. An important aspect Read more…

Removing duplicate values from an array in Swift

Arrays in Swift can hold on to all kinds of data. A common desire developers have when they use arrays, is to remove duplicate values from their arrays. Doing this is, unfortunately, not trivial. Objects that you store in an array are not guaranteed to be comparable. This means that it’s not always possible to determine whether two objects are the same. For example, the following model is not comparable: struct Point { let x: Int let y: Int } Read more…

Profiling and debugging your Combine code with Timelane

When we write code, we write bugs. It’s one of the laws of the universe that we can’t seem to escape. The tools we have to discover, analyze and fix these bugs are extremely important because without good debugging tools we’d be poking at a black box until we kind of figure out what might be happening in our code. Debugging synchronous code is hard enough already, but once your code involves several streams of asynchronous work debugging becomes much Read more…

What is @escaping in Swift?

If you’ve ever written or used a function that accepts a closure as one of its arguments, it’s likely that you’ve encountered the @escaping keyword. When a closure is marked as escaping in Swift, it means that the closure will outlive, or leave the scope that you’ve passed it to. Let’s look at an example of a non-escaping closure: func doSomething(using closure: () -> Void) { closure() } The closure passed to doSomething(using:) is executed immediately within the doSomething(using:) function. Read more…

What are computed properties in Swift and when should you use them?

One of Swift’s incredibly useful features is its ability to dynamically compute the value of a property through a computed property. While this is a super handy feature, it can also be a source of confusion for newcomers to the language. In this week’s post, I would like to take some time to explain computed properties in-depth so you can begin using them in your codebase with confidence. By the end of this post, you will have a solid understanding Read more…

Reading and writing Property List files with Codable in Swift

You have probably seen and used a property list file at some point in your iOS journey. I know you have because every iOS app has an Info.plist file. It’s possible to create and store your own .plist files to hold on to certain data, like user preferences that you don’t want to store in UserDefaults for any reason at all. In this week’s Quick Tip you will learn how you can read and write data from and to property Read more…