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.
- Host: GitHub
- URL: https://github.com/r8vnhill/echo-app-swift
- Owner: r8vnhill
- License: bsd-2-clause
- Created: 2025-04-02T00:29:25.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-04T23:27:23.000Z (about 1 year ago)
- Last Synced: 2025-04-09T22:43:00.011Z (about 1 year ago)
- Topics: cli, course-material, dibs-course, education, educational, modular-design, multi-module, software-libraries, software-library, starter-project, swift, swift-package-manager, swiftpm, teaching
- Language: Swift
- Homepage: https://dibs.pages.dev
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EchoAppSwift



[](https://dibs.pages.dev/docs/build-systems/init/swift/)
[](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)