### Objective-C Usage (iOS 12+) Source: https://github.com/dustturtle/realreachability2/blob/main/README.md Provides examples for starting and stopping network monitoring, listening for reachability changes via notifications, performing one-time checks, and configuring settings in Objective-C. ```objc #import // Start monitoring [[RRReachability sharedInstance] startNotifier]; // Listen for changes // Posted when reachability status or connection type changes [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kRRReachabilityChangedNotification object:nil]; - (void)reachabilityChanged:(NSNotification *)notification { RRReachabilityStatus status = [notification.userInfo[kRRReachabilityStatusKey] integerValue]; RRConnectionType type = [notification.userInfo[kRRConnectionTypeKey] integerValue]; BOOL isSecondaryReachable = [notification.userInfo[kRRSecondaryReachableKey] boolValue]; switch (status) { case RRReachabilityStatusReachable: if (isSecondaryReachable) { NSLog(@"Network reachable (secondary cellular fallback)"); } else { NSLog(@"Network reachable"); } break; case RRReachabilityStatusNotReachable: NSLog(@"Network not reachable"); break; default: break; } } // One-time check [[RRReachability sharedInstance] checkReachabilityWithCompletion:^(RRReachabilityStatus status, RRConnectionType type) { // Handle result }]; // Configuration [RRReachability sharedInstance].probeMode = RRProbeModeParallel; [RRReachability sharedInstance].timeout = 5.0; [RRReachability sharedInstance].periodicProbeEnabled = YES; // default: YES [RRReachability sharedInstance].allowCellularFallback = NO; // default: NO // allowCellularFallback requires HTTP participation (parallel/httpOnly) // when enabled on Wi-Fi, ObjC uses HTTP primary probe (cellular disabled) + fallback probe (cellular allowed) // when disabled on Wi-Fi, ObjC primary HTTP probing also keeps cellular disabled to avoid implicit fallback // Stop monitoring [[RRReachability sharedInstance] stopNotifier]; ``` -------------------------------- ### Swift Source Integration Usage Source: https://github.com/dustturtle/realreachability2/blob/main/README.md Example of how to check network reachability using the Swift API after source integration. ```swift // If files are added into the same app target, no module import is required. let status = await RealReachability.shared.check() ``` -------------------------------- ### Swift Build Command Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md Command to build the Swift project and show verbose output. ```bash swift build -v ``` -------------------------------- ### Swift Unit Tests Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md Command to run Swift unit tests. ```bash RealReachability2Tests.RealReachability2Tests ``` -------------------------------- ### HTTP Integration Test Sample Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md Sample name for an HTTP integration test. ```bash testHTTPProberWithShortTimeout ``` -------------------------------- ### Swift Usage (iOS 13+) Source: https://github.com/dustturtle/realreachability2/blob/main/README.md Demonstrates how to perform one-time checks, set up continuous monitoring, integrate with SwiftUI, and configure the reachability settings in Swift. ```swift import RealReachability2 // One-time check let status = await RealReachability.shared.check() switch status { case .reachable(let connectionType): print("Connected via \(connectionType)") case .notReachable: print("No internet connection") case .unknown: print("Status unknown") } // Continuous monitoring Task { for await status in RealReachability.shared.statusStream { print("Network status: \(status)") } } // SwiftUI usage .task { for await status in RealReachability.shared.statusStream { self.networkStatus = status } } // Configuration RealReachability.shared.configuration = ReachabilityConfiguration( probeMode: .parallel, // .parallel, .httpOnly, or .icmpOnly timeout: 5.0, httpProbeURL: URL(string: "https://www.gstatic.com/generate_204")!, icmpHost: "8.8.8.8" // Host for ICMP ping ) ``` -------------------------------- ### Swift ICMP Integration Test Sample Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md Sample name for a Swift ICMP integration test that may hang. ```bash testICMPPingerWithShortTimeout ``` -------------------------------- ### Objective-C ICMP Fallback Implementation Files Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md Files related to Objective-C ICMP fallback detection capability. ```text /RealReachability2/Sources/RealReachability2ObjC/RRPingFoundation.m ``` ```text RealReachability2/Sources/RealReachability2ObjC/RRReachability.m ``` -------------------------------- ### Swift Package Manager Target Products Source: https://github.com/dustturtle/realreachability2/blob/main/README.md Specify the product to use when integrating RealReachability2 via Swift Package Manager. ```swift // For Swift (iOS 13+) .product(name: "RealReachability2", package: "RealReachability2") // For Objective-C via SPM (iOS 13+) .product(name: "RealReachability2ObjC", package: "RealReachability2") ``` -------------------------------- ### README and SPM Platform Declaration File Paths Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md File paths related to the inconsistency between README and SPM platform declarations. ```text /RealReachability2/README.md:10 ``` ```text RealReachability2/Package.swift:8 ``` -------------------------------- ### Swift Concurrency Risk File Path Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md File path related to Swift 6 concurrency compatibility risk. ```text /RealReachability2/Sources/RealReachability2/RealReachability.swift:162 ``` -------------------------------- ### Swift ICMP Pinger File Path Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md File path related to a potential Swift ICMP ping issue. ```text /RealReachability2/Sources/RealReachability2/Prober/ICMPPinger.swift:45 ``` -------------------------------- ### Swift Package Manager Dependencies Source: https://github.com/dustturtle/realreachability2/blob/main/README.md Add the RealReachability2 library to your Swift Package Manager dependencies. ```swift dependencies: [ .package(url: "https://github.com/dustturtle/RealReachability2.git", from: "1.0") ] ``` -------------------------------- ### Stream Model Subscription File Paths Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md File paths related to the stream model's single subscription risk. ```text RealReachability2/Sources/RealReachability2/RealReachability.swift:95 ``` ```text RealReachability2/Sources/RealReachability2/Monitor/PathMonitorWrapper.swift:27 ``` -------------------------------- ### Objective-C Reachability File Path Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md File path related to a potential Objective-C reachability misjudgment. ```text /RealReachability2/Sources/RealReachability2ObjC/RRReachability.m:129 ``` -------------------------------- ### CI Filter Strategy File Paths Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md File paths related to imprecise CI filtering strategy. ```text /RealReachability2/.github/workflows/ci.yml:34 ``` ```text RealReachability2/.github/workflows/ci.yml:52 ``` -------------------------------- ### PathMonitor Restart Semantics File Path Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md File path related to PathMonitor restart semantics risk. ```text /RealReachability2/Sources/RealReachability2/Monitor/PathMonitorWrapper.swift:15 ``` -------------------------------- ### Objective-C Unit Tests Source: https://github.com/dustturtle/realreachability2/blob/main/checklist.md Identifier for Objective-C unit tests. ```bash RRReachabilityTests ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.