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
[ PROJECT ] → [ Swift Packages ] → [ + ]
[Enter the URL of the library you want to install] → [Next]
[Specify version (this time, use "Version")] → [Next] 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]
Make sure it has been added to the project
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.
Recommended Posts