[IOS]如何使用Swift Package Manager
视频参考: https://www.youtube.com/watch?v=xu9oeCAS8aA
Apple Guide: https://developer.apple.com/documentation/xcode/creating_a_swift_package_with_xcode
Swift Package Manager (SwiftPM) 是 Apple 推出的一个包管理工具, 用于创建, 使用 Swift 的库, 以及可执行程序的工具.
简要步骤如下:
1. Create a Swift Package
File > New > Swift Package

2. Configure Your Swift Package
// swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "MyLibrary",
platforms: [
.macOS(.v10_13),
],
products: [
.library(name: "MyLibrary", targets: ["MyLibrary"]),
],
dependencies: [
.package(url: "https://url/of/another/package/named/Utility", from: "1.0.0"),
],
targets: [
.target(name: "MyLibrary", dependencies: ["Utility"]),
.testTarget(name: "MyLibraryTests", dependencies: ["MyLibrary"]),
]
)
3. Organize Your Code with Swift Packages
Click the + button in the “Frameworks, Libraries, and Embedded Content” section and select the local package’s library to link it into your app target.