An open API service indexing awesome lists of open source software.

https://github.com/r8vnhill/echo-app-swift

๐Ÿ“ฆ A SwiftPM-based CLI project for learning modular design in Swift โ€” part of the Software Library Design and Implementation (DIBS) course. Includes a basic setup and a multi-module structure.
https://github.com/r8vnhill/echo-app-swift

cli course-material dibs-course education educational modular-design multi-module software-libraries software-library starter-project swift swift-package-manager swiftpm teaching

Last synced: 10 months ago
JSON representation

๐Ÿ“ฆ A SwiftPM-based CLI project for learning modular design in Swift โ€” part of the Software Library Design and Implementation (DIBS) course. Includes a basic setup and a multi-module structure.

Awesome Lists containing this project

README

          

# EchoAppSwift

![Swift](https://img.shields.io/badge/swift-6.1%2B-orange?logo=swift)
![License: BSD-2](https://img.shields.io/badge/license-BSD--2--Clause-green.svg)
![Platform](https://img.shields.io/badge/platform-linux%20%7C%20macOS%20%7C%20windows-lightgrey)
[![Lesson (ES) โ€“ Basic Project](https://img.shields.io/badge/ver%20lecci%C3%B3n-proyecto%20b%C3%A1sico-blueviolet)](https://dibs.pages.dev/docs/build-systems/init/swift/)
[![Lesson (ES) โ€“ Modular Project](https://img.shields.io/badge/ver%20lecci%C3%B3n-proyecto%20modular-blueviolet)](https://dibs.pages.dev/docs/build-systems/modular-design/swift/)

This repository accompanies two lessons on how to create and structure Swift projects using **Swift Package Manager (SwiftPM)**.

> ๐Ÿ“˜ **The lessons are written in Spanish**, but the repository and its structure are fully in English for broader accessibility:
>
> - [Lesson 1 โ€“ Basic Project Setup](https://dibs.pages.dev/docs/build-systems/init/swift/)
> - [Lesson 2 โ€“ Modular Project Design](https://dibs.pages.dev/docs/build-systems/modular-design/swift/)

## ๐Ÿ“ Project Structure

The project evolves in two stages:

1. **Initial structure**: A single Swift executable created with `swift package init --type executable`.
2. **Modular design**: The project is split into:
- `App`: An executable module.
- `Lib`: A reusable library module.
- `LibTests`: A unit test module for `Lib`.

```
EchoAppSwift/
โ”œโ”€โ”€ Package.swift
โ”œโ”€โ”€ Sources
โ”‚ โ”œโ”€โ”€ App
โ”‚ โ”‚ โ””โ”€โ”€ main.swift
โ”‚ โ””โ”€โ”€ Lib
โ”‚ โ””โ”€โ”€ Echo.swift
โ”œโ”€โ”€ Tests
โ”‚ โ””โ”€โ”€ LibTests
โ”‚ โ””โ”€โ”€ EchoTests.swift
โ””โ”€โ”€ README.md
```

This structure follows SwiftPM conventions strictly. Each folder name must match the declared targets in `Package.swift`.

## ๐Ÿงช What does it do?

You can run the app from the root with:

```bash
swift run App Kanna Kenji Friend
```

Expected output:

```text
Kanna
Kenji
Friend
```

## ๐Ÿ“ฆ What's inside?

- `Sources/Lib/Echo.swift`:
Defines a simple public function:

```swift
public func echo(_ message: String) -> String {
return message
}
```

- `Sources/App/main.swift`:
Entry point that uses `echo`:

```swift
import Lib

func main() {
let args = CommandLine.arguments.dropFirst()
for arg in args {
print(echo(arg))
}
}

main()
```

## ๐Ÿ’ก Learn More

These lessons guide you through:

- Installing Swift on Linux, macOS, or Windows.
- Using `swift package init` to bootstrap a project.
- Understanding `Package.swift` and SwiftPM conventions.
- Refactoring to a modular structure with a library and tests.
- Running and organizing Swift projects from the terminal.

Although written in Spanish, the code is accessible and the directory structure is self-explanatory.

## ๐Ÿ”— References

- [๐ŸŒ Swift Package Manager Documentation](https://www.swift.org/documentation/package-manager/)
- [๐Ÿ“ฐ Modular Project Structure with SwiftPM](https://santoshbotre01.medium.com/modular-project-structure-with-swift-package-manager-spm-c81fb62c8619)
- [๐ŸŽฅ How to Make a Swift Command Line Tool โ€“ YouTube](https://youtu.be/w7HvY29P9A4)