SwiftTextToolkit

main

SwiftTextToolkit is a lightweight and modular Swift package that provides utilities for working with text. It includes tools for counting words and characters, and for transforming strings into URL-safe slugs.
PalmeiraLabs/SwiftTextToolkit

SwiftTextToolkit

Tests

SwiftTextToolkit is a lightweight and modular Swift package that provides utilities for working with text in iOS and other Swift-based platforms. It includes tools to count words and characters, and to generate slugs from strings.

Perfect for developers looking for reusable and well-tested text-processing utilities.

โœจ Features

  • WordCounter: Count words and characters in a string, ignoring whitespace and newlines.
  • Slugifier: Create slugs from text with three levels of aggressiveness:
    • Fast (basic replacement)
    • Moderate (whitespace-aware)
    • Advanced (URL-friendly and cleaned)
  • Fully documented with DocC.
  • Built using Swift Package Manager.
  • 100% Swift-native and unit-tested.

๐Ÿ“ฆ Installation

Using Swift Package Manager

In your Package.swift file, add:

dependencies: [
    .package(url: "https://github.com/PalmeiraLabs/SwiftTextToolkit.git", from: "1.0.0")
]

Or from Xcode:

File โ†’ Add Packages โ†’ Paste the GitHub repository URL

๐Ÿš€ Example Usage

import SwiftTextToolkit

let toolkit = SwiftTextToolkit()

let text = "Hello, Swift world!"

let wordCount = toolkit.wordCounter.countWords(in: text)
// โ†’ 3

let slug = toolkit.slugifier.slugifyModerate(text: text)
// โ†’ "hello,-swift-world!"

๐Ÿ“š Documentation

Generated with DocC

๐Ÿ“ฆ Download offline documentation:
SwiftTextToolkit.doccarchive

๐Ÿงช Running Tests

This package includes unit tests for all major features.
Run tests with:

swift test

๐Ÿชช License

This project is licensed under a limited MIT-style license:

  • Free to use for personal or commercial purposes.
  • Modification and redistribution of modified versions are not allowed.
  • Provided without any warranties.

See the LICENSE file for more information.

โš ๏ธ Disclaimer

This software is provided "as is", without any express or implied warranties.
This means:

  • No guarantee it works perfectly or without bugs.
  • The author is not responsible for any damage or loss caused by its use.
  • You use this package at your own risk.

We recommend thorough testing before using it in critical projects.

Author

Agustin Palmeira / PalmeiraLabs

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Apr 09 2026 01:27:59 GMT-0900 (Hawaii-Aleutian Daylight Time)