Skip to content

Commit

Permalink
Update readme instructions & version (#164)
Browse files Browse the repository at this point in the history
* update readme instructions & version

* add full package example

* Update README.md

Co-authored-by: Franz Busch <privat@franz-busch.de>

* Update README.md

Co-authored-by: Franz Busch <privat@franz-busch.de>

* add getting started to docc index

---------

Co-authored-by: Franz Busch <privat@franz-busch.de>
  • Loading branch information
tib and FranzBusch authored Jan 25, 2024
1 parent 0503127 commit b21c43a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
1 change: 0 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// swift-tools-version:5.7

import PackageDescription

let package = Package(
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,29 @@ To add a dependency on the package, declare it in your `Package.swift`:
and to your application target, add `ServiceLifecycle` to your dependencies:

```swift
.target(name: "MyApplication", dependencies: [.product(name: "ServiceLifecycle", package: "swift-service-lifecycle")]),
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle")
```

Example `Package.swift` file with `ServiceLifecycle` as a dependency:

```swift
// swift-tools-version:5.9
import PackageDescription

let package = Package(
name: "my-application",
dependencies: [
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.3.0"),
],
targets: [
.target(name: "MyApplication", dependencies: [
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle")
]),
.testTarget(name: "MyApplicationTests", dependencies: [
.target(name: "MyApplication"),
]),
]
)
```

### Using ServiceLifecycle
Expand Down
40 changes: 40 additions & 0 deletions Sources/ServiceLifecycle/Docs.docc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,46 @@ to their business logic if and how to do that.
Library authors should conform their services to the ``Service`` protocol and application authors
should use the ``ServiceGroup`` to orchestrate all their services.

## Getting started

If you have a server-side Swift application or a cross-platform (e.g. Linux, macOS) application, and you would like to manage its startup and shutdown lifecycle, Swift Service Lifecycle is a great idea. Below you will find all you need to know to get started.

### Adding the dependency

To add a dependency on the package, declare it in your `Package.swift`:

```swift
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.3.0"),
```

and to your application target, add `ServiceLifecycle` to your dependencies:

```swift
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle")
```

Example `Package.swift` file with `ServiceLifecycle` as a dependency:

```swift
// swift-tools-version:5.9
import PackageDescription

let package = Package(
name: "my-application",
dependencies: [
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.3.0"),
],
targets: [
.target(name: "MyApplication", dependencies: [
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle")
]),
.testTarget(name: "MyApplicationTests", dependencies: [
.target(name: "MyApplication"),
]),
]
)
```

## Topics

### Articles
Expand Down

0 comments on commit b21c43a

Please sign in to comment.