티스토리 뷰

반응형

🎅 간단 요약 🎄

https://github.com/apple/swift-package-manager/blob/master/Documentation/Usage.md

 

 

[1] 깃헙에 레포지토리를 하나 만듭니다

 

 

[2] 소스트리에 클론해줍니다 

 

[3] 해당 폴더에 들어가서 SPM을 만들어줍니다. 

명렁어: swift package init

 

 

[4]  빌드가 잘 되는 지 확인합니다

명령어: swift build

 

 

[5] 테스트를 잘 돌리는 지 확인합니다

명령어: swift test 

 

 

[6] 프로젝트를 만들어줍니다

명령어: swift package generate-xcodeproj 

 

 

그리고 프로젝트가 잘 열리는 지 열어봅니다 

명령어: xed .

(현재 폴더에 있는 프로젝트를 열어주는 명령어입니다) 

 

 

이렇게 잘 열렸습니다. 

 

 

 

 

예전에는 이렇게 구성되어있었는데,

 

 

이렇게 프로젝트가 생겼습니다. 

 

 

[7] (옵션) dependencies를 설정해줍니다

 

현재 Package.swift에 가보면 dependencies가 이렇게 되어있는데,

만약에 SPM이 의존하는 라이브러리가 있다면 추가해줍니다

 

예를 들어 Alamofire라면 이렇게 해줍니다..!! 

 

 

그리고 빌드가 잘되는 지 확인해보세요 

 

(저는 일단 빼주겠겠습니다)

 

참고로 라이브러리를 추가하고 빼면 Package.resolved에 변경사항이 잡히는 것을 볼 수 있습니다.

 

 

여기 읽어 보면 Package.resolved 가 Podfile.lock과 비슷한 것 같습니다. 

Resolving Versions (Package.resolved File)


The package manager records the result of dependency resolution in a Package.resolved file in the top-level of the package, and when this file is already present in the top-level, it is used when performing dependency resolution, rather than the package manager finding the latest eligible version of each package. Running swift package update updates all dependencies to the latest eligible versions and updates the Package.resolved file accordingly.

Resolved versions will always be recorded by the package manager. Some users may choose to add the Package.resolved file to their package's .gitignore file. When this file is checked in, it allows a team to coordinate on what versions of the dependencies they should use. If this file is gitignored, each user will separately choose when to get new versions based on when they run the swift package update command, and new users will start with the latest eligible version of each dependency. Either way, for a package which is a dependency of other packages (e.g., a library package), that package's Package.resolved file will not have any effect on its client packages.

The swift package resolve command resolves the dependencies, taking into account the current version restrictions in the Package.swift manifest and Package.resolved resolved versions file, and issuing an error if the graph cannot be resolved. For packages which have previously resolved versions recorded in the Package.resolved file, the resolve command will resolve to those versions as long as they are still eligible. If the resolved version's file changes (e.g., because a teammate pushed a new version of the file) the next resolve command will update packages to match that file. After a successful resolve command, the checked out versions of all dependencies and the versions recorded in the resolved versions file will match. In most cases the resolve command will perform no changes unless the Package.swift manifest or Package.resolved file have changed.

Most SwiftPM commands will implicitly invoke the swift package resolve functionality before running, and will cancel with an error if dependencies cannot be resolved.

 

(출처: https://github.com/apple/swift-package-manager/blob/master/Documentation/Usage.md#resolving-versions-packageresolved-file

 

 

 

 

 

그리고 소스트리에서 여태까지 추가된 파일들을 커밋해주면 됩니다 :-)
아직 추가한 코드가 없으니까 깃헙에서 릴리즈 태그는 아직 달지 않겠습니다

커밍쑨~ 
(이 포스팅에서 코드추가하고 릴리즈 태그달고 SPM 적용한 부분이 나옵니다)

 

 

 

 

여기 글도 참고해보면 좋을 것 같아요~ 

https://www.raywenderlich.com/1993018-an-introduction-to-swift-package-manager

 

An Introduction to Swift Package Manager

In this introduction to the Swift Package Manager, you’ll build a website to display random idioms. You’ll learn how to manage projects and dependencies and how to read and change Package.swift files.

www.raywenderlich.com

 

반응형
댓글