Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. iOS
  3. SwiftyTimer

SwiftyTimer

MITSwift2.1.0

A modern Swift API for NSTimer with intuitive closure syntax and time interval helpers.

Visit WebsiteGitHubGitHub
1.2k stars135 forks0 contributors

What is SwiftyTimer?

SwiftyTimer is a Swift library that provides a modern, Swifty API wrapper around Apple's NSTimer. It simplifies scheduling delays and repeating timers in iOS, macOS, watchOS, and tvOS apps by replacing verbose Objective-C patterns with clean closure syntax and intuitive time interval helpers. The library solves the problem of cumbersome timer management in Swift, making code more readable and expressive.

Target Audience

Swift developers building apps for Apple platforms (iOS, macOS, watchOS, tvOS) who need to manage timers with less boilerplate and more type safety.

Value Proposition

Developers choose SwiftyTimer for its elegant API that feels native to Swift, eliminating Objective-C cruft with features like closure-based scheduling, intuitive time helpers (e.g., `5.seconds`), and inline timer invalidation. It reduces code complexity while maintaining full control over timer behavior.

Overview

Swifty API for NSTimer

Use Cases

Best For

  • Replacing verbose NSTimer target-selector patterns with Swift closures
  • Scheduling repeating animations or UI updates in iOS/macOS apps
  • Implementing countdowns or delays with readable time expressions
  • Managing background tasks with configurable run loop modes
  • Simplifying timer invalidation logic within callback closures
  • Writing cleaner, more expressive timer code in Swift projects

Not Ideal For

  • Projects built entirely with SwiftUI that leverage Combine's Timer publishers for reactive programming
  • Applications requiring nanosecond-level precision or direct access to low-level timer APIs like mach_absolute_time
  • Teams with strict policies against third-party dependencies for core functionality like timers
  • Developers who prefer using Grand Central Dispatch (GCD) for all scheduling tasks due to its concurrency model and performance

Pros & Cons

Pros

Closure-Based Scheduling

Replaces verbose Objective-C target-selector patterns with clean Swift closures, making timer code more readable and less error-prone, as demonstrated in the README with examples like `Timer.every(0.7.seconds) { statusItem.blink() }`.

Intuitive Time Expressions

Provides natural time helpers such as `5.seconds` and `100.ms`, allowing intervals to be expressed in a human-readable way without manual unit conversions, enhancing code clarity and reducing bugs.

Flexible Timer Control

Offers manual scheduling with `new(after:)` and `new(every:)`, plus configurable run loop modes via `start(modes:)`, giving developers fine-grained control over timer execution and integration with different app states.

Inline Invalidation

Enables conditional timer invalidation within the callback by passing a Timer argument, simplifying logic for stopping timers based on runtime conditions, as shown in the README with the `timer.invalidate()` example.

Cons

Foundation Bug Workaround

Relies on `new(after:)` and `new(every:)` methods instead of proper initializers due to a known bug in Foundation, which can feel less idiomatic and might confuse developers expecting standard Swift initialization patterns.

Inherits NSTimer Limitations

As a wrapper around NSTimer, it carries over issues like timing inaccuracies and dependency on run loops, making it unsuitable for applications requiring high-precision scheduling or real-time performance.

No Modern Concurrency Support

Lacks integration with Swift's newer concurrency models such as async/await or Combine, limiting its usefulness in projects adopting these technologies for timer-based operations and reactive programming.

Platform Lock-in

Exclusively supports Apple platforms (iOS, macOS, watchOS, tvOS), so it cannot be used in cross-platform Swift projects targeting environments like Linux or Windows, restricting its versatility.

Frequently Asked Questions

Quick Stats

Stars1,234
Forks135
Contributors0
Open Issues6
Last commit2 years ago
CreatedSince 2015

Tags

#ios#swifty#tvos#timer#watchos#swift#scheduling#closures#macos#api-wrapper

Built With

S
Swift

Links & Resources

Website

Included in

iOS51.7kSwift26.0k
Auto-fetched 1 day ago

Related Projects

SwiftDateSwiftDate

🐔 Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift.

Stars7,696
Forks774
Last commit2 years ago
DateToolsDateTools

Dates and times made easy in iOS

Stars7,180
Forks939
Last commit2 years ago
AsyncAsync

Syntactic sugar in Swift for asynchronous dispatches in Grand Central Dispatch

Stars4,557
Forks311
Last commit2 years ago
TimepieceTimepiece

Intuitive date handling in Swift

Stars2,607
Forks141
Last commit6 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub