Swift Package Manager (SPM)

Swift Package Manager
SPM

Getting Started

배포

  1. target 폴더로 이동

  2. 터미널에서 swift package init 입력. 몇 가지 파일이 생긴다

  3. 핵심이 되는 Package.swift 파일 설정

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "JNomaKit",
    platforms: [
        .iOS(.v13)
    ],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "JNomaKit",
            targets: ["JNomaKit"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "JNomaKit",
            dependencies: []),
        .testTarget(
            name: "JNomaKitTests",
            dependencies: ["JNomaKit"]),
    ]
)
  1. 소스코드 작성

  2. Git 작업

    • github repository 생성
    • git init
    • git remote add origin {repo url}
    • git add .
    • git commit -m "{commit 메시지}"
    • git push --set-upstream origin master

사용하기

이미 SPM이 적용된 프로젝트를 clone해온 경우 File -> Packages -> Update를 해줘야 한다

  1. Xcode File 탭 -> add Packages -> repo url 입력

  2. File -> Packages -> Update to Latest Package Versions

좋은 웹페이지 즐겨찾기