# An Introduction to Swift Package Manager and how it works

DevFeed: [An Introduction to Swift Package Manager and how it works](<https://devfeed.tech/articles/an-introduction-to-swift-package-manager-and-how-it-works-24750.md>)

Original publisher: [Read original article](<https://medium.com/ymedialabs-innovation/an-introduction-to-swift-package-manager-and-how-it-works-cfe8e0d8cbd3?source=rss----8b5620c36355---4>)

Author: prateek arora

Published: 2023-04-11T05:00:35Z

Content type: tutorial

Language: en

Sources: [ymedialabs-innovation](<https://devfeed.tech/sources/ymedialabs-innovation-medium.md>)

Topics: [swift-package-manager](<https://devfeed.tech/topics/swift-package-manager.md>), [Package Management](<https://devfeed.tech/topics/package-management.md>), [swift-package](<https://devfeed.tech/topics/swift-package.md>), [cocoapods](<https://devfeed.tech/topics/cocoapods.md>), [Swift](<https://devfeed.tech/topics/swift.md>)

Tags: [package-management](<https://devfeed.tech/tags/package-management.md>), [spm](<https://devfeed.tech/tags/spm.md>), [swift](<https://devfeed.tech/tags/swift.md>), [swift-package](<https://devfeed.tech/tags/swift-package.md>), [swift-package-manager](<https://devfeed.tech/tags/swift-package-manager.md>), [swiftpm](<https://devfeed.tech/tags/swiftpm.md>)

## AI overview

Swift Package Manager (SPM) is integrated with Swift's build system to download, compile, and link dependencies; the text says it is included with Swift 3.0 and later. It supports macOS, iOS, tvOS, and Linux, with Xcode 11 or later required on macOS; Linux users must install it manually or use swiftenv. The article presents built-in Xcode integration and automatic handling of transitive dependencies as advantages over third-party tools such as CocoaPods and Carthage. It also lists limitations: no support for build phases or build settings, no support for .xcodeproj files, and packages cannot be deployed directly to a device or simulator. For SwiftLint, it describes creating a parallel SPM project to build and run the executable. The setup walkthrough creates a Swift package in Xcode, pushes it to a remote repository, then adds that repository to an app through Xcode's Package Dependencies interface and links the package under Link Binary with Libraries.

## Source excerpt

What is a package Manager? A package manager or package-management system is a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer in a consistent manner. or A package manager deals with packages, distributions of software and data in archive files. Packages contain metadata, such as the software's name, description of its purpose, version number, vendor, checksum (preferably a cryptographic hash function), and a list of dependencies necessary for the software to run properly. What is Swift Package Manager (SPM) As per official Apple Swift Documentation: "The Swift Package Manager is a tool for managing the distribution of Swift code. It's integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies." The Package Manager is included in Swift 3.0 and above. Why do we need Swift Package Manager? Though we have multiple other ways to manage the dependencies like cocoa pods, Carthage etc. then why is there a need to use SPM? The answer is both cocoa pods and Carthage are third-party package managers, which eventually leads to extra code and efforts one has to put in order to utilise these third-party package managers. For example: For cocoa pods, we need to have a pod framework to be installed, which then needs ruby, gem file or brew in order to install pods. But then SPM comes inbuilt with XCode, so there won't be extra effort and extra files that will be getting added once we use SPM. System Requirement SwiftPM is compatible with macOS, iOS, tvOS and Linux For macOS, you need XCode 11 and above. For Linux, you have to install it manually or use swiftenv. Advantages SwiftPM is open-source like Cocoapods. It may be challenging or fast to contribute but it is possible. Ease of managing dependency's dependencies. If a dependency relies on another dependency, the Swift Package manager will handle it for you. Ease of resetting, manag