

Hook it to the ViewController class by clicking the ViewController.swift file with Option/Alt key and dragging it using the right mouse button.Ĥ.

Open Main.storyboard and create a label there in the center and add constraints to center it in the superview.ģ. We will name the app “BitcoinValue” where we will display the current Bitcoin value in USD.Ģ. Let’s create an empty iOS project in Xcode (we’re using Xcode 11.6 on macOS 10.15.6 in this tutorial).
#SWIFT PACKAGE MANAGER BUILD TIME HOW TO#
In the second section, I will explain how to create modules for your app using SPM.ġ. In the first one, you probably won’t learn anything new because we will create and set up a project to use it in the next section. I’ve divided this tutorial into two main sections. Swift Package Manager Tutorial: Creating a Modular iOS App Step by Step Thankfully, more and more frameworks are available to use with SPM. You just need to open the project in Xcode and then it is automatically fetching and installing all required dependencies. Thanks to this, fetching and installing dependencies is now an automated process. It is evolving and in 2019 it was integrated into Xcode - the main tool for Apple platforms development. SPM (Swift Package Manager) is built to do exactly the same thing but is written in Swift and its purpose is to make it easier to manage dependencies in a project. You might have heard of CocoaPods or Carthage. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. The Swift Package Manager is a tool for managing the distribution of Swift code. And, as you hopefully already know, a cleaner codebase means faster work in the future.Īs we can read on the official Swift website:
#SWIFT PACKAGE MANAGER BUILD TIME CODE#
In other words, this approach makes our codebase cleaner by separating the independent parts of our code into modules.

Modular programming is what you need then to clean this all up! Modular programming is the process of subdividing a computer program into separate sub-programs. I bet you know from your own experience, how having too many files messes the whole project in terms of its clarity. And also - many files to do it properly, using the principles of clean code. If you have ever built a big application that was fetching data from a server, saving data on the device, or calculating a lot - you know, that it requires many lines of code. Moreover, it is a big step further in making the coding easier, especially if we will think about iOS apps modularly. It has a big potential for a very useful tool for managing dependencies. Every iOS developer that watches Worldwide Developers Conference, or watched it in 2019 at least, heard about something called “Swift Package Manager”.
