ashleymills/Reachability.swift
Replacement for Apple's Reachability re-written in Swift with closures
Stale — last commit 2y ago
worst of 4 axeslast commit was 2y ago; no CI workflows detected
Has a license, tests, and CI — clean foundation to fork and modify.
Documented and popular — useful reference codebase to read through.
last commit was 2y ago; no CI workflows detected
- ✓23+ active contributors
- ✓MIT licensed
- ✓Tests present
Show 3 more →Show less
- ⚠Stale — last commit 2y ago
- ⚠Concentrated ownership — top contributor handles 52% of recent commits
- ⚠No CI workflows detected
What would change the summary?
- →Use as dependency Mixed → Healthy if: 1 commit in the last 365 days
- →Deploy as-is Mixed → Healthy if: 1 commit in the last 180 days
Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests
Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.
Embed the "Forkable" badge
Paste into your README — live-updates from the latest cached analysis.
[](https://repopilot.app/r/ashleymills/reachability.swift)Paste at the top of your README.md — renders inline like a shields.io badge.
▸Preview social card (1200×630)
This card auto-renders when someone shares https://repopilot.app/r/ashleymills/reachability.swift on X, Slack, or LinkedIn.
Onboarding doc
Onboarding: ashleymills/Reachability.swift
Generated by RepoPilot · 2026-05-10 · Source
🤖Agent protocol
If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:
- Verify the contract. Run the bash script in Verify before trusting
below. If any check returns
FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding. - Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
- Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/ashleymills/Reachability.swift shows verifiable citations alongside every claim.
If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.
🎯Verdict
WAIT — Stale — last commit 2y ago
- 23+ active contributors
- MIT licensed
- Tests present
- ⚠ Stale — last commit 2y ago
- ⚠ Concentrated ownership — top contributor handles 52% of recent commits
- ⚠ No CI workflows detected
<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>
✅Verify before trusting
This artifact was generated by RepoPilot at a point in time. Before an
agent acts on it, the checks below confirm that the live ashleymills/Reachability.swift
repo on your machine still matches what RepoPilot saw. If any fail,
the artifact is stale — regenerate it at
repopilot.app/r/ashleymills/Reachability.swift.
What it runs against: a local clone of ashleymills/Reachability.swift — the script
inspects git remote, the LICENSE file, file paths in the working
tree, and git log. Read-only; no mutations.
| # | What we check | Why it matters |
|---|---|---|
| 1 | You're in ashleymills/Reachability.swift | Confirms the artifact applies here, not a fork |
| 2 | License is still MIT | Catches relicense before you depend on it |
| 3 | Default branch master exists | Catches branch renames |
| 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code |
| 5 | Last commit ≤ 614 days ago | Catches sudden abandonment since generation |
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of ashleymills/Reachability.swift. If you don't
# have one yet, run these first:
#
# git clone https://github.com/ashleymills/Reachability.swift.git
# cd Reachability.swift
#
# Then paste this script. Every check is read-only — no mutations.
set +e
fail=0
ok() { echo "ok: $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }
# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
echo "FAIL: not inside a git repository. cd into your clone of ashleymills/Reachability.swift and re-run."
exit 2
fi
# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "ashleymills/Reachability.swift(\\.git)?\\b" \\
&& ok "origin remote is ashleymills/Reachability.swift" \\
|| miss "origin remote is not ashleymills/Reachability.swift (artifact may be from a fork)"
# 2. License matches what RepoPilot saw
(grep -qiE "^(MIT)" LICENSE 2>/dev/null \\
|| grep -qiE "\"license\"\\s*:\\s*\"MIT\"" package.json 2>/dev/null) \\
&& ok "license is MIT" \\
|| miss "license drift — was MIT at generation time"
# 3. Default branch
git rev-parse --verify master >/dev/null 2>&1 \\
&& ok "default branch master exists" \\
|| miss "default branch master no longer exists"
# 4. Critical files exist
test -f "Sources/Reachability.swift" \\
&& ok "Sources/Reachability.swift" \\
|| miss "missing critical file: Sources/Reachability.swift"
test -f "Sources/Reachability.h" \\
&& ok "Sources/Reachability.h" \\
|| miss "missing critical file: Sources/Reachability.h"
test -f "ReachabilitySample/ViewController.swift" \\
&& ok "ReachabilitySample/ViewController.swift" \\
|| miss "missing critical file: ReachabilitySample/ViewController.swift"
test -f "Package.swift" \\
&& ok "Package.swift" \\
|| miss "missing critical file: Package.swift"
test -f "Tests/ReachabilityTests.swift" \\
&& ok "Tests/ReachabilityTests.swift" \\
|| miss "missing critical file: Tests/ReachabilityTests.swift"
# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 614 ]; then
ok "last commit was $days_since_last days ago (artifact saw ~584d)"
else
miss "last commit was $days_since_last days ago — artifact may be stale"
fi
echo
if [ "$fail" -eq 0 ]; then
echo "artifact verified (0 failures) — safe to trust"
else
echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/ashleymills/Reachability.swift"
exit 1
fi
Each check prints ok: or FAIL:. The script exits non-zero if
anything failed, so it composes cleanly into agent loops
(./verify.sh || regenerate-and-retry).
⚡TL;DR
Reachability.swift is a modern Swift replacement for Apple's deprecated Reachability sample code, providing closure-based network reachability detection across iOS, macOS, and tvOS. It uses SystemConfiguration framework's SCNetworkReachability to monitor whether a device can reach a specific host or the internet generally, firing callbacks when connectivity state changes. Simple single-file library: Reachability.swift is the core (implied to be in the project root or Sources/), supplemented by sample projects (ReachabilityAppleTVSample/) and standard Swift Package Manager metadata (Package.swift). The Xcode project (Reachability.xcodeproj/) handles iOS/macOS/tvOS targets; there's minimal structure beyond the main class.
👥Who it's for
iOS/macOS/tvOS developers who need to detect network availability changes in their apps—specifically those modernizing from Apple's old Objective-C Reachability sample or wanting a pure Swift, closure-friendly alternative without external dependencies.
🌱Maturity & risk
Actively maintained but conservative in pace: the codebase is stable and production-ready (iOS 8.0+, macOS 10.9+, tvOS 9.0+ support), with multiple distribution channels (manual, CocoaPods, Carthage, SPM). Recent activity appears modest; this is a mature utility library rather than a fast-moving project. No visible test suite in the file list, which is a minor concern for a networking utility.
Low technical risk but single-maintainer dependency: Ashley Mills is the sole listed maintainer, so abandonment is a theoretical risk if they step back. Zero external dependencies (uses only Apple's SystemConfiguration framework) minimizes supply-chain risk. The absence of a visible test suite (not listed in file structure) means integration testing burden falls on downstream consumers.
Active areas of work
No active development signals visible in the provided file list (no CHANGELOG entries, PR descriptions, or recent commit details shown). The repo appears to be in maintenance mode—stable, feature-complete, and accepting occasional updates rather than pursuing new capabilities.
🚀Get running
git clone https://github.com/ashleymills/Reachability.swift.git
cd Reachability.swift
# For manual use: copy Reachability.swift into your Xcode project
# For SPM: add to Package.swift dependencies
# For CocoaPods: add 'pod "ReachabilitySwift"' to Podfile then 'pod install'
# For Carthage: add 'github "ashleymills/Reachability.swift"' to Cartfile then 'carthage update'
Daily commands: This is a library, not an app: include Reachability.swift in your project and call it. The tvOS sample (ReachabilityAppleTVSample/ViewController.swift) demonstrates usage; open Reachability.xcodeproj in Xcode and run the sample scheme to see it in action.
🗺️Map of the codebase
Sources/Reachability.swift— Core reachability monitoring engine; implements network status detection, closure-based callbacks, and all public APIs—essential for understanding the library's behavior.Sources/Reachability.h— Objective-C bridging header exposing the Reachability class for mixed-language projects and documentation; defines public interface.ReachabilitySample/ViewController.swift— iOS reference implementation demonstrating typical usage patterns (initialization, listener setup, status checking) for the main target platform.Package.swift— Swift Package Manager manifest defining build targets, dependencies, and deployment platform constraints for all supported environments.Tests/ReachabilityTests.swift— Test suite validating network status detection, reachability state transitions, and closure callback behavior under various network conditions.README.md— User-facing documentation covering installation, usage examples, and platform compatibility; critical for understanding library scope and API conventions.
🧩Components & responsibilities
- Reachability (Swift class) (Swift, SystemConfiguration, DispatchQueue) — Central orchestrator: wraps SCNetworkReachability, manages listener registration, invokes closures on network status changes, thread-safe queuing of callbacks.
- Failure mode: If startNotifier() is not called, callbacks never fire; if stopNotifier() is not called, the listener persists and may cause memory leaks.
- SCNetworkReachability (System Framework) (C API, kernel network stack) — Low-level network status monitor; polls kernel network state and fires callbacks when reachability changes.
- Failure mode: Callback may not fire on network transitions if runloop is blocked; hostname resolution failures will report unreachable.
- Sample Apps (iOS, macOS — undefined
🛠️How to make changes
Add a Custom Network Status Handler
- Define a new closure property in a sample app's ViewController to handle reachability changes (e.g., custom logging, analytics). (
ReachabilitySample/ViewController.swift) - Register the closure with Reachability's
whenReachableorwhenUnreachablecallbacks inviewDidLoad()or similar lifecycle method. (ReachabilitySample/ViewController.swift) - Implement your custom logic (UI updates, API calls, cache invalidation) inside the closure and test with unit tests. (
Tests/ReachabilityTests.swift)
Support a New Apple Platform
- Update
Package.swiftto add the new platform to the.ios,.macos, or.tvosplatform list with minimum OS version. (Package.swift) - Create a new sample app folder (e.g.,
ReachabilityWatchOSSample/) following the structure of existing samples. (ReachabilitySample) - Copy and adapt AppDelegate and ViewController from an existing sample (e.g., ReachabilitySample/), adjusting for the new platform's lifecycle and UI patterns. (
ReachabilitySample/AppDelegate.swift) - Add integration tests in
Tests/ReachabilityTests.swiftto verify reachability detection works on the new platform. (Tests/ReachabilityTests.swift)
Extend Reachability with Additional Status Types
- Open
Sources/Reachability.swiftand extend theConnectionenum or add new enum cases for custom network states (e.g.,.slowNetwork,.metered). (Sources/Reachability.swift) - Implement detection logic using SCNetworkReachability flags to determine when the new status applies (e.g., check
isExpensiveflag). (Sources/Reachability.swift) - Update the status getter or add helper methods to return the new connection type based on current network flags. (
Sources/Reachability.swift) - Add test cases in
Tests/ReachabilityTests.swiftto verify the new status is correctly detected and callbacks fire appropriately. (Tests/ReachabilityTests.swift)
🔧Why these technologies
- SystemConfiguration Framework (SCNetworkReachability) — Native Apple framework for low-level network reachability monitoring; provides efficient event-driven callbacks via system-level network status changes without polling.
- Swift with closure-based callbacks — Modern Swift idiom replacing Apple's delegate-based Reachability; more concise, flexible, and enables functional programming patterns for status handling.
- DispatchQueue for thread safety — Ensures callbacks execute on specified queue (typically main queue for UI updates); prevents race conditions in multi-threaded scenarios.
- Swift Package Manager — Standard modern distribution method for Swift libraries; simplifies dependency management across iOS, macOS, tvOS, and future platforms.
- CocoaPods support — Maintains backward compatibility with existing projects still using CocoaPods for dependency management.
⚖️Trade-offs already made
-
Event-driven (callback-based) architecture vs. polling
- Why: SCNetworkReachability provides native system callbacks, reducing CPU and battery overhead compared to periodic polling.
- Consequence: Requires proper listener lifecycle management (startNotifier/stopNotifier); incorrect cleanup can leak resources or cause dangling references.
-
Single-threaded closure execution on main queue by default
- Why: Simplifies UI updates and matches UIKit's main-thread requirement; reduces developer burden.
- Consequence: Long-running operations in callbacks block the main thread; developers must dispatch heavy work to background queues manually.
-
No built-in retry logic or connection pooling
- Why: Keeps the library lightweight and focused on status detection; higher-level concerns deferred to application code.
- Consequence: Apps must implement their own retry strategies, exponential backoff, and failover logic for network operations.
-
Closure-based API instead of delegate pattern
- Why: More idiomatic in Swift; supports multiple listeners and simplifies API surface.
- Consequence: Developers unfamiliar with closures may find the API less intuitive than older Objective-C delegate patterns.
🚫Non-goals (don't propose these)
- Does not provide latency measurement or bandwidth estimation; only binary reachability status.
- Does not implement connection multiplexing, pooling, or advanced HTTP features; that is the responsibility of URLSession or third-party networking libraries.
- Does not handle DNS resolution or domain-specific reachability checks beyond hostname-based monitoring.
- Does not provide real-time connection quality metrics (signal strength, packet loss); only connection type (WiFi, cellular, none).
- Not a complete networking stack; intended as a lightweight companion to URLSession or Alamofire.
🪤Traps & gotchas
No visible hidden traps, but note: (1) SystemConfiguration framework requires linked framework in your Xcode project settings—manual integration can miss this. (2) Network reachability is asynchronous and can race with UI updates; closure handlers may fire on background threads (check the actual implementation for thread guarantees). (3) No test suite means upgrading requires manual integration testing. (4) Closure-based API (pre-async/await) can lead to callback nesting; modern Swift developers may want to wrap it in async functions.
🏗️Architecture
💡Concepts to learn
- SystemConfiguration Framework (SCNetworkReachability) — This library is a thin wrapper around SCNetworkReachability; understanding how Apple's low-level network monitoring API works is key to debugging reachability edge cases
- Closure-based callbacks vs. Delegation — Reachability.swift replaces Apple's NSURLConnection delegate pattern with Swift closures; this design choice enables more concise syntax but differs from older iOS patterns
- Network Reachability vs. Connectivity — Reachability detects path availability, not actual internet access; a device can have a network interface but no internet—a common source of bugs in apps using this library
- Thread safety in asynchronous callbacks — SystemConfiguration callbacks may fire on background threads; any Reachability-based UI updates need explicit main-thread dispatch, a common gotcha
- Multi-platform Swift package management (iOS, macOS, tvOS) — This library targets three Apple platforms with different deployment minimums; understanding SPM's platform specifications and Xcode scheme configuration is necessary to extend it
- Closure memory management and weak self — Storing reachability closures can create reference cycles; callers must use [weak self] to avoid leaking objects, a critical pattern in this library's usage
🔗Related repos
tonymillion/Reachability— The original Objective-C Reachability library that inspired this Swift rewrite; useful for understanding the underlying SystemConfiguration patternsAlamofire/Alamofire— Popular HTTP networking library with built-in reachability monitoring; an alternative for teams already using Alamofirekishikawakatsumi/Reachability.swift— Alternative modern Reachability wrapper; compare different API designs and closure patternsapple/swift-nio— Apple's async networking framework; relevant for teams modernizing to Swift Concurrency beyond this library's closure modelashleymills/Screenshot-Producer— The creator's own app ecosystem; demonstrates real-world usage of Swift tooling and AppStore distribution (tangential but shows the maintainer's active iOS development)
🪄PR ideas
To work on one of these in Claude Code or Cursor, paste:
Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.
Add Swift Package Manager (SPM) integration tests and CI workflow
Package.swift exists but there's no CI workflow (no .github/workflows directory visible) to verify SPM builds succeed across iOS, macOS, and tvOS platforms. This is critical for a library distributed via SPM, as broken package manifests can silently fail for users.
- [ ] Create .github/workflows/spm-build.yml to test
swift buildon macOS with iOS, macOS, and tvOS targets - [ ] Verify Package.swift correctly declares platforms and dependencies for all supported OS versions
- [ ] Add a test to ensure the library builds without warnings when integrated as a Swift Package dependency
Add unit tests for Reachability.swift core functionality
The file structure shows three sample apps (ReachabilitySample, ReachabilityAppleTVSample, ReachabilityMacSample) but no Tests/ directory is visible. The core Reachability library needs unit tests covering connection state changes, closure callbacks, and multi-platform behavior to ensure reliability across iOS, macOS, and tvOS.
- [ ] Create Tests/ directory with ReachabilityTests.swift containing XCTestCase subclasses
- [ ] Add tests for network state transitions (WiFi → Cellular → None) using mock SCNetworkReachability
- [ ] Add tests verifying closure callbacks fire correctly on connection changes
- [ ] Add platform-specific tests for iOS, macOS, and tvOS using #if os() preprocessor directives
Add GitHub Actions CI for minimum deployment target validation
README claims compatibility with iOS 8.0+, OSX 10.9+, and tvOS 9.0+, but there's no CI to verify code actually builds against these minimum deployment targets. Xcode's default targets can silently use newer APIs, breaking compatibility for users on older OS versions.
- [ ] Create .github/workflows/deployment-target-check.yml to compile against minimum OS versions declared in Package.swift and .xcodeproj
- [ ] Add swiftlint or similar static analysis to catch use of unavailable APIs (e.g., APIs requiring iOS 9+ in iOS 8.0 target)
- [ ] Document the minimum Swift language version requirement (currently absent from Package.swift manifest)
🌿Good first issues
- Add XCTest unit tests: create Tests/ReachabilityTests.swift with test cases for reachability state transitions, closure firing, and edge cases like network changes mid-connection. Currently missing entirely.
- Document thread safety guarantees: the README mentions 'closures' but doesn't specify whether callbacks fire on main thread or background thread. Add a section to README.md and docstring comments clarifying this, with usage examples showing if dispatch to main is needed.
- Add modern Swift Concurrency wrapper: create an async/await version of the reachability API (e.g.,
AsyncReachability) or provide helper methods to bridge closures to async sequences, easing adoption by newer projects.
⭐Top contributors
Click to expand
Top contributors
- @ashleymills — 52 commits
- @hamchapman — 13 commits
- @connorpower — 9 commits
- @tommyming — 3 commits
- @albinjohnson01 — 2 commits
📝Recent commits
Click to expand
Recent commits
21d1dc4— Update ReachabilitySwift.podspec (ashleymills)1932dcd— Merge pull request #420 from albinjohnson01/master (ashleymills)f50ae05— Merge pull request #1 from albinjohnson01/albinjohnson01-patch-1 (albinjohnson01)11599b4— Update PrivacyInfo.xcprivacy (albinjohnson01)7cbd73f— Update ReachabilitySwift.podspec (ashleymills)ca3b095— Merge pull request #416 from marcuseckert/master (ashleymills)d5894ad— fixed privacy manifest (Marcus Eckert)57da4b1— Update ReachabilitySwift.podspec (ashleymills)bf39476— Merge pull request #413 from adzerjitchii/fix-privacy-manifest (ashleymills)50f8010— Fix report generation by adding empty items to CollectedDataType and APITypes (adzerjitchii)
🔒Security observations
The Reachability.swift codebase is a network reachability utility library with moderate security posture. Primary concerns include: (1) incomplete security vulnerability reporting policy that lacks contact information and response procedures, (2) outdated platform support targeting versions from 2018 which may lack modern security features, and (3) inability to fully assess dependency security due to missing Package.swift content. The library itself, being a system wrapper for network reachability APIs, has limited attack surface for injection or credential issues. Recommendations focus on updating documentation, modernizing minimum OS support, completing security policies, and implementing automated dependency scanning.
- High · Incomplete Security Policy —
SECURITY.md. The SECURITY.md file contains a template with placeholder text ('Use this section to tell people...') that has not been filled in. This indicates the vulnerability reporting process is not properly documented, making it difficult for security researchers to report issues responsibly. Fix: Complete the SECURITY.md file with: 1) Clear instructions on how to report vulnerabilities (e.g., security@example.com or a dedicated form), 2) Expected response times, 3) Disclosure policy, 4) Whether rewards are offered - Medium · Missing or Incomplete Dependency Information —
Package.swift. The Package.swift file content was not provided in the analysis. Without visibility into dependencies, it's impossible to verify if the project uses any outdated or vulnerable third-party libraries. The Reachability.swift project uses System frameworks (SystemConfiguration, Network) which require validation for security updates. Fix: Provide complete Package.swift content and implement regular dependency scanning using tools like: 1) Swift Package Manager audit, 2) Dependabot for automated updates, 3) Regular security advisories review - Medium · Outdated Platform Support Documentation —
README.md. The README indicates compatibility with iOS 8.0-12.0, OSX 10.9-10.14, and tvOS 9.0-12.0. These are significantly outdated OS versions (iOS 12 released 2018). Supporting outdated platforms may expose users to unpatched security vulnerabilities and prevent use of modern security APIs. Fix: 1) Update minimum supported OS versions to current Apple recommendations (iOS 13+, macOS 10.15+, tvOS 13+), 2) Remove support for obsolete versions, 3) Update documentation to reflect current support matrix, 4) Use latest security APIs available in supported OS versions - Low · Missing Swift Package Manifest Metadata —
Package.swift. No Package.swift content was provided, making it impossible to verify security-related manifest settings such as package platforms, swift-tools-version, and security classifications. Fix: Ensure Package.swift includes: 1) Explicit swift-tools-version (3.1 or later recommended), 2) Clear platform version specifications, 3) Proper package description and metadata, 4) Consider adding 'platforms' directive for explicit OS support - Low · PrivacyInfo.xcprivacy Requires Validation —
Sources/PrivacyInfo.xcprivacy. The project includes PrivacyInfo.xcprivacy file (required by Apple for apps using sensitive APIs), but content was not available for review. This file must accurately describe any APIs and data accessed by the Reachability framework. Fix: Verify that PrivacyInfo.xcprivacy accurately declares: 1) Any system frameworks used (SystemConfiguration, Network), 2) Whether location data, device IDs, or other sensitive data is accessed, 3) Compliance with Apple's privacy requirements as of the latest iOS version
LLM-derived; treat as a starting point, not a security audit.
👉Where to read next
- Open issues — current backlog
- Recent PRs — what's actively shipping
- Source on GitHub
Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.