I have an interest in the Swift Package Manager. And, I tried contributing it by sending pull requests.
But, I feel it is NOT known many developers. The reason might be that it's still in early design and development.
So, I will write stories about it in detail dividing several times.
? INFORMATION: It’s often shortened to "SwiftPM" or "SPM". Also, it seems that projects and libraries are called "package". So, I use "SwiftPM" and "package" in my stories.
SPM-0001: Let's Try the Swift Package Manager
I recommend the former because I think it's easier.
By the way, it's liable to be realized the same dependency manager as CocoaPods and Carthage because the name has the word "Package Manager".
But, it seems that it's different from them. We can BUILD our package via SwiftPM WITHOUT Xcode.
Let's try SwiftPM! ?
Downloading and Installing
First, it's necessary to download Development Snapshots from Swift.org. Then, you can get a package file.
Next, install the package file according to the direction on your screen.
By default, it's located in
For your information, please try using
tryswiftdev if you feel it is TIRESOME.
It might make EASY for you to download and install new Development Snapshots. ?
Create an empty directory for a new package in advance.
If using a Terminal.app, type the following command in an optional directory.
$ mkdir NewPackageName
Type the following command in a Terminal.app to change directory into the new package directory.
$ cd path/to/NewPackageName
Select an initializing mode and type the following command in a Terminal.app to initialize a new package.
- executable (default)
$ swift build --init Creating executable package: PackageName Creating Package.swift Creating .gitignore Creating Sources/ Creating Sources/main.swift Creating Tests/
$ swift build --init=library Creating library package: PackageName Creating Package.swift Creating .gitignore Creating Sources/ Creating Sources/PackageName.swift Creating Tests/ Creating Tests/LinuxMain.swift Creating Tests/PackageName/ Creating Tests/PackageName/PackageNameTests.swift
Let's try building a package.
For now, SwiftPM supports the following configurations.
- debug (default)
executable - debug:
$ swift build Compile Swift Module ‘PackageName’ (1 sources) Linking .build/debug/PackageName
library - debug:
$ swift build Compile Swift Module ‘PackageName’ (1 sources)
executable - release:
$ swift build -c release Compile Swift Module ‘PackageName’ (1 sources) Linking .build/release/PackageName
library - release:
$ swift build -c release Compile Swift Module ‘PackageName’ (1 sources)
That’s all for this story.
I will publish a continuation of the story later! ?