Archive

Posts from the original WordPress blog, preserved for reference.


These posts were originally published between 2019 and 2021. Some code examples may reference older versions of Swift or SwiftUI, but I've kept them here for reference.

2021

15 posts

Recently I was working on a SwiftUI project were I needed to know when my app became active from being in the background. Like most things in SwiftUI, I found out that this was really simple to implement in my project.

Oct 1, 2021 2 min read Read Post

This is a short post about an issue I recently had with updating a widget for a SwiftUI project. I kept getting a weird error every time I tried to run a widget target in the simulator. The error read “Failed to initialize client context with error”. This was followed by a crazy long error message spit out by the debug console in Xcode. I googled everything and I finally found the solution! (Note: This only happened on my M1 Mac)

Sep 18, 2021 1 min read Read Post

Recently Apple has announced AsyncImage at WWDC 2021. This makes loading images from a URL very easy in SwiftUI projects supporting iOS 15 and above. Let’s take a look at an example below.

Jun 24, 2021 2 min read Read Post

Recently I ran into an error when trying to run a SwiftUI Project on my iPhone. I’m running this project on a M1 Macbook Pro. The error seemed to start happening when my project started using certain Cocoapods. The error reads “ARCHS[@]: unbound variable”.

May 18, 2021 1 min read Read Post

In this post we are going to look at how we can implement a launch screen in our SwiftUI project. In the past we would usually have to use a storyboard or XIB file to make our launch screens. In SwiftUI, we can now use the Info.plist to make our launch screen.

May 8, 2021 3 min read Read Post

In this post we are going to look at how we can add a Swift package to our SwiftUI Project. Let’s start by going to the Swift Package Index website and searching through the libraries. For this post we are going to use the SwiftUICharts package to add to our project.

Mar 24, 2021 2 min read Read Post

In this post we are going to make a custom HUD view with a timer. The timer will dismiss our HUD view after about a second. Our HUD view will be similar to the pop up view we see on our screen when we put our phone into silent mode.

Mar 10, 2021 3 min read Read Post

In this post we are going to take a look at the different ways we can style a picker view in our SwiftUI project. Let’s first setup a simple picker view like in the example below.

Feb 22, 2021 2 min read Read Post

Recently I have been working on a new project with my new M1 Macbook Pro. In this project I needed to use third party libraries such as FBSDKCoreKit (Facebook) so the user could sign in with their Facebook account. The problem I ran into was that no matter what I did the Cocoapods I loaded into my project would not run. Xcode would give me error messages such as “No such module found” or “module ‘FBSDKCoreKit’ not found”.

Feb 16, 2021 2 min read Read Post

When you create a new SwiftUI project, you will see that we no longer have the AppDelegate.swift file. This doesn’t mean we don’t need or use the AppDelegate file anymore. If we want to implement something like push notifications we will need to use an AppDelegate in our SwiftUI app. Let’s take a look at how we can add an AppDelegate file to our SwiftUI project.

Feb 15, 2021 2 min read Read Post

Appstorage is a property wrapper for getting stored values from UserDefaults in SwiftUI. We use @Appstorage too reload our body view property whenever the value changes of our UserDefaults. This keeps our view up to date with the data that we have stored. Let’s take a look at an example on how we can use @Appstorage in our SwiftUI project.

Feb 8, 2021 1 min read Read Post

Code snippets are shortcuts to blocks of boilerplate code that we use most often when programming. Xcode allows us to add custom snippets to the many pre-existing snippets that Apple provides. Let’s see how we can make a code snippet out of the following code below.

Jan 29, 2021 2 min read Read Post

In this post we are going to take a look at how we can add a tab bar view to our SwiftUI app. Tab bar views are used to display a view when the tab item is selected. For this example we will simply have two tab views that will show a text view with a different background color. Let’s start by creating our example views that we will assign to our tab bar.

Jan 18, 2021 2 min read Read Post

In this post we are going to take a look at how we can get JSON data from an API and show it in a list view in SwiftUI. Let’s jump right in a get started by creating a new SwiftUI project.

Jan 11, 2021 4 min read Read Post

Making a phone call from a SwiftUI app is easy and only takes a few lines of code to implement. All we need to do is setup a button that will open the phone app and make a phone call with a phone number we pass in.

Jan 3, 2021 2 min read Read Post

2020

47 posts

@StateObject and @ObservedObject are very similar in that they both keep track of an objects state. The difference is @StateObject is owned by the view it was created in where as @ObservedObject is owned by another view.

Dec 23, 2020 1 min read Read Post

SwiftUI makes opening a URL with your default web browser super easy with the Link view. All you need to do is give it a title and a destination URL. Let us take a look at the example below.

Dec 11, 2020 1 min read Read Post

SwiftUI makes it easy to add a blur effect to any view. All we need to do is add the .blur() modifier to our view. Let’s see how we can apply this by looking at the example below.

Dec 3, 2020 1 min read Read Post

SF Symbols are set of over 2,000 symbols created by Apple for developers to use in there apps. SF Symbols are dynamic. This means that they will automatically align with the size and weight of text in our app. We can use these symbols for almost anything but they are most commonly used in toolbars, menus, and navigation bars.

Nov 23, 2020 1 min read Read Post

What is Access Controls in Swift? According to the documentation “Access control restricts access to parts of your code from code in other source files and modules. This feature enables you to hide the implementation details of your code, and to specify a preferred interface through which that code can be accessed and used.” We can implement access controlS by adding five different types of modifiers to our code. These modifiers are:

Nov 11, 2020 1 min read Read Post

In this post we are going to learn how to make a SwiftUI button that expands out to show more button options. Below is an example of what our button will look like when we are finished.

Oct 23, 2020 3 min read Read Post

SwiftUI allows us to add our own custom views and modifiers to Xcode’s library. By doing this we are able to easily access our custom views and add them into our code in just a click. Let’s see how we can take advantage of this in our own SwiftUI project.

Oct 17, 2020 5 min read Read Post

As of iOS 14 we can now use the new .redacted(reason:) modifier in SwiftUI to make placeholders for our views. Let’s take a look at the example below to get a better understanding of how we can add placeholders to our SwiftUI project.

Oct 8, 2020 4 min read Read Post

Sign in with Apple makes it safe and secure for users to login to websites and apps. We can implement Sign in with Apple easily with SwiftUI 2. For us to use Sign in with Apple in our app we are required to use iOS 14 or later and Xcode 12 or later.

Sep 28, 2020 4 min read Read Post

Sidebars are really useful for navigating on bigger screen such as iPad’s and the Mac’s. We are going to take a look at how we can implement sidebars into a multiplatform SwiftUI app.

Sep 22, 2020 4 min read Read Post

At WWDC 2020 Apple introduced ProgressView’s to SwiftUI. A ProgressView allows us to show either a circular progress view or a linear progress view for when tasks are loading in our app.

Sep 17, 2020 3 min read Read Post

As of iOS 14 and SwiftUI 2 we can now add a pop out menu to any button in our app. We can implement this by using the new Menu keyword. Menus in some way are going to replace the current action sheets used in iOS apps. The problem with action sheets is they only show up at the bottom of our screen. This doesn’t look great on larger screens like the iPad and Mac. Menus allow the flexibility in where we would want to show pop out menus in our app instead of only showing them at the bottom of our screens.

Sep 2, 2020 3 min read Read Post

As of WWDC 2020, SwiftUI has made it insanely easy to add keyboard shortcuts to any SwiftUI app. Let’s look at how we can add keyboard shortcuts to our project by looking at the code example below.

Aug 19, 2020 2 min read Read Post

As of iOS 14, SwiftUI now gives developers two new UI components called LazyVGrid and LazyHGrid. LazyVGrid is used for creating vertical grids and LazyHGrid is used for horizontal grids. The keyword Lazy means that the grids view does not create items for the grid until they are needed to appear on screen. This allows our app to have much faster loading times when using grids!

Aug 5, 2020 4 min read Read Post

SwiftUI makes it really simply to detect when dark mode is enabled. We simply have to add a @Enviroment variable and use .colorScheme property to scan the settings on our device and see if dark mode is enabled.

Jul 20, 2020 1 min read Read Post

The reason I’m writing this post is because I had submitted a WatchOS side project I was working on (Status of Github) to the app store. The problem was that I submitted the app with all complications activated but had no image or placeholders for the complications (How embarrassing 🤦🏻‍♂️). So let’s jump into the project and fix this issue by setting a image to our complications.

Jul 13, 2020 3 min read Read Post

At WWDC 2020 disclosure groups were announced for SwiftUI. Disclosure groups are very similar to how drop down menus work on the Mac. Apple’s documentation defines it as “A view that shows or hides another content view, based on the state of a disclosure control”.

Jul 8, 2020 3 min read Read Post

In this post we are going to take a look at how to customize images in SwiftUI.

Jul 1, 2020 2 min read Read Post

In this post we are going to take a quick look at how to style text in SwiftUI.

Jun 19, 2020 2 min read Read Post

A Closure is a block of code that can pass around data. Closure’s are similar to functions but have special attributes. One feature of what makes closure’s special is that the block of code inside the closure can live passed the function they are called in. It does this by retaining a copy of the closures code in memory until it finishes executing. More about that in a bit, let’s look at an example of a simple closure below.

May 30, 2020 3 min read Read Post

A optional in Swift is the handling of nil in a variable. We check to see if our value is nil by a process we call unwrapping. Similar to a box that came in the mail, we have no idea if the box has anything inside or if it has nil inside. The only way to find out is by unwrapping it. Let’s look at a example to see how we can handle unwrapping optionals.

May 24, 2020 2 min read Read Post

If you have done any development with UIKit you have used a life cycle function. These UIKit life cycle functions would be viewDidLoad, viewWillAppear, viewWillDisappear, and viewDidDisappear. In SwiftUI we lose these life cycle functions because there are no more ViewControllers in SwiftUI, only views. SwiftUI replaces these functions with two methods called onAppear( ) and onDisappear( ).

May 21, 2020 1 min read Read Post

In Swift our view controllers have life cycle methods. Knowing your apps life cycle is really important for developers to understand how there app works. In this post we are going to run through all the life cycle methods we should know about when developing in iOS.

May 21, 2020 3 min read Read Post

What is a variadic function? A Variadic function takes in multiple arguments as a parameter. The swift compiler automatically organizes variadic function objects into an array. The arguments of a variadic function are shown by three periods (…) after the argument’s type. A good everyday example of this would be a print statement where you can print multiple objects.

May 12, 2020 1 min read Read Post

What is ARC? ARC stands for Automatic Reference Counting. Reference counting is a way of storing number references or pointer to a object. In short ARC helps to store references into memory and helps clean up memory when it is not being used.

Apr 27, 2020 3 min read Read Post

A secure textfield allows us to display a editable text area that hides the text the user inputs. In this post I will show you how easy it is to implement a secure textfield in a SwiftUI project.

Apr 25, 2020 2 min read Read Post

What is a Enum? Apple defines and enum as “a common type for a group of related values and enables you to work with those values in a type-safe way within your code”. What the heck does that mean? A enum is shorthand for enumeration and gives us a way to use fixed names for values rather than using strings or integers. Let’s take a look at an example to better explain how to use a enum.

Apr 23, 2020 3 min read Read Post

At the 2019 WWDC, Apple announced Sign in with Apple which allows users to sign into applications and websites securely. Sign in with Apple ensures privacy by not tracking your sensitive information and also provides a synchronous experience across all your Apple devices. The best part is that it is offered in browsers for platforms like Android and Windows devices through Sign in with Apple JS.

Apr 19, 2020 5 min read Read Post

In this quick post we are going to look at how we can make views in SwiftUI have rounded corners. You can round the corners of any SwiftUI view by using the cornerRadius() modifier. Simply add a value to the cornerRadius to control how rounded you want the view to be. Let us look at a simple example below.

Apr 10, 2020 1 min read Read Post

Apple’s latest update now includes support for you to connect a mouse or a trackpad to your iPad in iPadOS 13.4! This is really cool but how can we implement this in our own SwiftUI app for iPad. The good news is Apple makes this simple by giving us two modifiers .hoverEffect and .onHover to add to our SwiftUI views. Let us start by opening up Xcode and in a SwiftUI project add the following code.

Apr 2, 2020 2 min read Read Post

A ternary operator takes a condition and then returns either true or false depending on the value of the condition. The basic syntax can be seen in the example below.

Apr 1, 2020 1 min read Read Post

Testing how your app works in different networking conditions is really important before you release an app. As of Xcode 11, testing different network conditions built right to make our lives easier.

Mar 27, 2020 2 min read Read Post

A switch statement is used to check a variable against a list of possible cases for that variable to then execute. It looks for the first case that matches your variable you want to check and then runs that cases block of code. When that case is finished running its code it will break out from the switch statement.

Mar 19, 2020 2 min read Read Post

In this post we are going to take a look at how to show an alert in SwiftUI!

Mar 14, 2020 2 min read Read Post

In this post we are going to see how we can add haptic feedback to a button in SwiftUI. Apple gives us preset haptic options for us to choose from in the UINotificationFeedbackGenerator class. The haptics we can choose from are as follows:

Mar 11, 2020 2 min read Read Post

In this article we are going to make a simple map in SwiftUI. This map will show the users location and show how we can set pins (annotations) on our map.

Mar 8, 2020 4 min read Read Post

I love using keyboard shortcuts on my Macbook! I especially love using shortcuts in Xcode because it really helps my productivity. When using keyboard shortcuts I sometimes feel like I have magic powers being able to move around Xcode with ease. Below is a list of my most commonly used shortcuts.

Mar 3, 2020 2 min read Read Post

This is a short tutorial about how to use random and shuffle in swift. Let’s get started by opening up a swift playground in Xcode or on the iPad. Copy the code below into your playground

Feb 25, 2020 3 min read Read Post

Lazy variables in swift allow us to delay the creation of objects and only use them when the app needs them. Lazy variables help to utilize memory for expensive processes.

Feb 22, 2020 2 min read Read Post

In this tiny tutorial we are going to learn how to use the map() in Swift. The map() function is used to iterate and transform elements in an array. To get a better understanding of this let’s look at some examples.

Feb 19, 2020 2 min read Read Post

Today we are going to learn how to make an image carousel for displaying images in your app. Image carousels are a great way to show your user multiple images with only using a small amount of screen real estate.

Feb 12, 2020 4 min read Read Post

UIActivityViewController is a class that makes sharing content to other services on your apple device super simple. All you need to do is tell it what kind of content you want to share and UIActivityViewController take care of most of the heavy lifting. Here is how to implement it.

Feb 6, 2020 3 min read Read Post

What are property wrappers? Property wrappers in SwiftUI can be described as _@_State, @Binding, @ObservedObject, @EnvironmentObject, and @Environment. Let’s go through each one and get a better understanding of how to use these property wrappers to help us program in SwiftUI.

Jan 14, 2020 2 min read Read Post

How I learned to retrieve JSON data from API’s was by using CocoaPods like AlamoFire and AFNetworking. These Cocoapods make it easy to call an API for some piece of data but these libraries come with a lot of extra things I just don’t use most of the time in my app. So now I have been trying to use Apple’s solution by using Codable and URLSession.

Jan 14, 2020 4 min read Read Post

Recently I have been work on a little side project using SwiftUI in a stand alone watchOS app. When building my watchOS I was confused as to where I put the icon for my app since there are two Asset.xcassets file.

Jan 4, 2020 1 min read Read Post

In this tutorial we are going to look at how to make a Form in SwiftUI. The Form view helps make things like sign in sheets very simple and fast to setup in your app. With just a few simple lines of code you will have a form up and running. Let’s get started with making a contact form sheet.

Jan 2, 2020 5 min read Read Post

2019

8 posts

In this article we are going to learn how to use the NavigationView library to navigate from one view to another in SwiftUI. We will look at the most basic way to transition from a view using a button and a NavigationLink.

Dec 26, 2019 2 min read Read Post

I recently purchased a new Mac and when transferring everything over from my old Mac to my new Mac I forgot to setup wireless debugging in Xcode. I love not having to have your iPhone or iPad connected to your Mac to run your code and debug. I have been taking advantage of this feature since WWDC 2017 and its become such a big part of how I test and run my code on my devices. When I didn’t have this feature turned on in Xcode on my new Mac I thought something was broken or wrong with Xcode. Once you have this enabled you will feel the same way!

Dec 17, 2019 2 min read Read Post

The first time launch in an application is important for displaying things like tutorials to teach the user how to use your application or showing terms and service agreements. The problem is how do you know when was the users first time launching your app. For the best way to implement this we will need to head over to the AppDelegate.swift file. Then we will need to create a global variable outside of the AppDelegate methods like this.

Dec 14, 2019 2 min read Read Post

In SwiftUI, to present a modal view we need to use a new display modifier called sheets. To present a view modally we first need to start by creating a new SwiftUI file and name it ModalPresentedView. Go to File > New > File and choose iOS > User Interface > SwiftUI View. Then add the code below to our Modal view.

Nov 19, 2019 2 min read Read Post

Did you know that you can write SwiftUI code on your iPad! Apple’s update to Swift Playgrounds on the iPad now supports SwiftUI! This means we can build SwiftUI components anywhere we can take our iPads. This is really exciting because this brings developers one step closer to making iOS apps on the iPad (One day we will get Xcode for iPad 😕).

Nov 18, 2019 1 min read Read Post

As of this posting I was having a problem with an Apple Watch app I was trying to make using SwiftUI. The problem was text was not wrapping around my view that was nested in a ScrollView and VStack. I found that by adding these modifiers to your text will giving you multiple lines for text! Happy Coding!

Nov 5, 2019 1 min read Read Post

In short the SceneDelegate.swift file is there to help with the new multi-window support that was announced with iOS 13.

Oct 26, 2019 1 min read Read Post

Oct 2, 2019 1 min read Read Post

Back to top

Back to top

© 2025 Thomas Prezioso Jr. All rights reserved.

Built with Swift using Ignite