Use Swift Package with Xcode

Explaining how to use Swift Package conveniently with Xcode.

Introduction

Since Xcode 11, we can add or remove Swift Package by GUI operation.

Apple guide you in Xcode 11 Release Notes as follows:

./images/figure_01.png

The existing package managers CocoaPods and Carthage are the mainstream, but Xcode has supported Swift Package Manager, it seems that the overtaking stance will be spurred.

How to use

Adding a Swift Package in Xcode is easy. Open your Xcode project, Click File > Swift Packages > Add Package Dependency....

./images/figure_11.png

Enter the URL that provides the Swift Package.

./images/figure_12.png

Specify the version. It seems that you can also specify the branch and commit number.

./images/figure_13.png

Specifies to use the Swift Package to load to Target. See the Add Target column in the figure below.

./images/figure_14.png

Loading is completed by the above operations.

It can check the loaded Swift Package on the Info tab of the Xcode project. You can add or remove from there.

./images/figure_15.png