Create a framework with Swift Package Manager

Swift Package Manager or SPM is a fairly new addition to Xcode which allows you to add dependencies to your project easily. What if we want to create our own project? It’s actually pretty easy. The first is through the command line. We first create a directory, initialize it with SPM and generate an Xcode project.

mkdir MyPackage
cd MyPackage
swift package init
swift package generate-xcodeproj

That’s it!

You should now have the following files

Package.swift
README.md
Sources
Tests
MyPackage.xcodeproj

The Package.swift file is the main file to notice here. It is a configuration file for your package. The rest of the files are self explanatory.