### SwiftPM
○ Swift is a cross-platform language and SwiftPM is a cross-platform build system for Swift packages
○ Xcode support for Swift packages is built on top of it
○ Swift packages can now be used natively in apps on all Apple's platforms
### SwiftPM commands
| Command | Description |
|:----------:|-----------------------|
| build | to build a package |
| run | to run the executable products |
| tests | to run tests |
| package | to perform various nonbuild operations on the package |
### swift package subcommands
| Subcommand | Description |
|:----------:|-----------------------|
| clean | delete build artifacts |
| describe | describe the current package |
| reset | reset the complete cache/build directory |
| resolve | resolve package dependencies (transitively) |
| show-dependencies | print the resolved dependency graph |
| update | update package dependencies |
| ... | |
### swift package resolve
#### Package.swift
```swift
// swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "MyLibrary",
dependencies: [
.package(url: "https://github.com/bow-swift/bow",
from: "{version}")
]
)
```
#### swift package resolve
repositories/checkouts-state.json
```json
...
"https://github.com/bow-swift/bow.git": {
"repositoryURL": "https://github.com/bow-swift/bow.git",
"status": "available",
"subpath": "bow-674f37f5"
}
...
```
repositories/bow-674f37f5/packed-refs
```json
...
3dda4dbb9d2ee5b77a1aa9a6b8e1bc043b02c774 refs/tags/0.1.0
0a01cd1e3c686685654beb8bab044fcba59e1dc2 refs/tags/0.2.0
be51ef766d0f137a1d68351031c99db0579cfe0a refs/tags/0.3.0
ac3c035f44d6c4bad14a934a74105de6da190682 refs/tags/0.4.0
41e0d583c2d165371fa5dd8be11e2eb3b474056b refs/tags/0.5.0
fc4d6fc63cba4402e906f82aa223195afac3d4c2 refs/tags/0.6.0
...
```
dependencies-state.json
```json
...
"state": {
"checkoutState": {
"branch": null,
"revision": "fc4d6fc63cba4402e906f82aa223195afac3d4c2",
"version": "0.6.0"
},
"name": "checkout"
},
"subpath": "bow"
...
```
### Swift package describe
| Attribute | Type |
|:----------------:|:---------------------------:|
| name | String |
| c99name | String |
| type | library - executable - test |
| module_type | SwiftTarget - ClangTarget |
| path | String |
| sources | [String] |
#### .build/checkouts/bow
```json
"c99name": "Bow",
"module_type": "SwiftTarget",
"name": "Bow",
"path": ".../.build/checkouts/bow/Sources/Bow",
"sources": [
...
"Typeclasses/Applicative.swift",
"Typeclasses/ApplicativeError.swift",
"Typeclasses/Bimonad.swift",
"Typeclasses/Comonad.swift",
"Typeclasses/Traverse.swift",
...
],
"type": "library"
```
## Closing the circle
### __nef__ ♡ __iPad__
#### NefSwiftPlayground
swift package resolve
swift package describe
```json
...
"c99name": "Bow",
"module_type": "SwiftTarget",
"name": "Bow",
"path": ".../.build/checkouts/bow/Sources/Bow",
"sources": [
...
],
"type": "library"
...
```
EnvIO<Shell, SwiftPlaygroundError, [Module]>
```swift
(Shell) -> IO<SwiftPlaygroundError, [Module]>
```
-----------------
```swift
IO<SwiftPlaygroundError, [Module]>
```
```swift
IO models a suspended computation that produces
side effects and returns a value of type [Module],
or produces an error of type SwiftPlaygroundError
```
#### Given a Package.swift
```swift
// swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "BowTestProject",
dependencies: [
.package(url: "https://github.com/bow-swift/bow",
from: "0.7.0")
]
)
```
#### nef Xcode Editor Extension
#### __nef__ ♡ SwiftPM
#### __nef__ ♡ Swift Playground 3.1
## Xcode Editor Extension
### DEMO