Add Swift Package Dependency to an iOS Project With Xcode 11Remote, local, public, private and customAntoine BarraultBlockedUnblockFollowFollowingJun 10We used to use CocoaPods or Carthage to add a third party library into an iOS project.
But now, due to Xcode 11, we can add a Swift package directly from the Xcode menu.
Adding a New Swift PackageGo to File > Swift Packages > Add Package Dependency.
Browse your GitHub repositoriesWhen you add a new package, it will prompt a Choose Package Repository interface, where you will see all your Swift package repositories, as long as you are logged into GitHub inside Xcode.
Fetching a custom repositoryBut you can also specify an URL manually; just type it into the search field.
When you’ve entered a manual URL, or when you’ve selected your required repository — tap next.
Choosing the right rule to fetch the repositoryNow that you’ve selected the project, you need to choose which part of the code you want to look at.
You can select a version number, a branch, or a specific commit.
When you click ‘Next’, Xcode will try to fetch the project from the branch, a specific version or revision commit.
Selecting the target to add the framework toIf everything works, you will see a final screen in which you choose where you will add the Swift package.
That’s it!.You’ve just added a Swift framework to your iOS project with Swift package manager.
Fetching a Repository on Your ComputerIt is also possible to add a local repository to your iOS project.
As the Choose package repository interface supports URI, you can add the path of the local folder that contains your Swift framework using file:// as prefix.
Just remember that you need to have a Git Repository initialized in the folder you want to add.