Let's use Swift Package Manager (SwiftPM) ~ Introduction ~

About SwiftPackageManager (hereinafter, SwiftPM), which can be used for iOS application development from Xcode 11 and has become considerably easier to use with Xcode 12 released the other day, this article is out of how to introduce it to the project and how to create your own library to SwiftPM It will be an introduction method.

↓ Click here for how to create

What is Swift PM

How to install the library

Installation environment

Add package

[ PROJECT ] → [ Swift Packages ] → [ + ] スクリーンショット 2020-10-05 11.04.29.png

[Enter the URL of the library you want to install] → [Next]

[Specify version (this time, use "Version")] → [Next] スクリーンショット 2020-10-05 11.33.26.png The version specification method is as follows.

type Contents
Version Specify a specific version or range of versions
Branch Specify the branch name
Commit Specify the commit ID

In addition, you can specify more options in "Version".

type Contents Example Meaning of example
Up to Next Major Above the specified version and less than the next major version 1.0.0 < 2.0.0 1.0.0 or more and 2.0.Less than 0
Up to Next Minor Above the specified version and less than the next minor version 1.0.0 < 1.3.0 1.0.0 or more and 1.3.Less than 0
Range More than the specified version and less than the specified version 1.0.0 < 1.5.0 1.0.0 or more and 1.5.Less than 0
Exact Specify a specific version 1.0.0 1.0.0

[Check the addition destination with "Add to Target"] → [Finish] スクリーンショット 2020-10-07 15.11.28.png

Make sure it has been added to the project スクリーンショット 2020-10-07 15.12.17.png

The above is the library installation method in Swift PM. How to call is the same as other libraries

ViewController.swift


//
//  ViewController.swift
//  SwiftPMTest
//
//  Created by Isami Odagiri on 2020/10/03.
//

import UIKit
import Nuke

You can use it with.

reference

Recommended Posts

Let's use Swift Package Manager (SwiftPM) ~ Introduction ~
Let's use Swift Package Manager (SwiftPM) ~ Creation ~
[Swift] Let's use extension
[Swift] Let's use Segmented Control
Let's use Swift Firebase Firebase Auth
Let's use Twilio in Java! (Introduction)
Let's use jcmd
Let's use Java New FileIO! (Introduction, for beginners)
Where I got stuck with Swift Package Manager support
Let's try Zoomdata (Introduction)