Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion NetworkTools.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/imsankalp/react-native-network-tools.git", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm,cpp}"
s.private_header_files = "ios/**/*.h"

# NetworkToolsManager.h is public so Swift AppDelegates can call
# [NetworkToolsManager activate] after `import NetworkTools`.
s.public_header_files = "ios/NetworkToolsManager.h"

# DEFINES_MODULE = YES tells CocoaPods to generate an umbrella header +
# module map for this pod and inject -fmodule-map-file into every dependent
# target's xcconfig, which is what makes `import NetworkTools` work in Swift
# without use_frameworks!. (Same mechanism used by RNReanimated et al.)
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }

install_modules_dependencies(s)
end
45 changes: 42 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ If you use Expo Development Builds, add the plugin to `app.json`:

## Quick Start

### 1. Configure OkHttpClient (Android)
### 1a. Configure OkHttpClient (Android)

Add the interceptor to your `MainApplication.kt`:

Expand Down Expand Up @@ -62,6 +62,44 @@ class MainApplication : Application(), ReactApplication {
}
```

### 1b. Register the URLProtocol interceptor (iOS)

Add the activation call to your `AppDelegate.swift`:

```swift
import NetworkTools

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
#if DEBUG
NetworkToolsManager.activate()
#endif

// rest of your setup
return true
}
```

For Objective-C `AppDelegate.mm`:

```objc
#import <NetworkTools/NetworkToolsManager.h>

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#if DEBUG
[NetworkToolsManager activate];
#endif
// rest of your setup
return YES;
}
```

If you use **Expo**, the plugin patches both `MainApplication` and `AppDelegate` automatically during `expo prebuild` — no manual steps needed.

### 2. Wrap Your App with NetworkMonitorProvider

```typescript
Expand Down Expand Up @@ -165,9 +203,10 @@ For Expo validation, see the [Expo smoke test](docs/EXPO_SMOKE_TEST.md).
| --- | --- | --- |
| React Native Android (New Architecture) | ✅ Supported | TurboModule path |
| React Native Android (Old Architecture) | ✅ Supported | Legacy bridge fallback |
| Expo Development Build + Prebuild (Android) | ✅ Supported | Use config plugin |
| React Native iOS (New Architecture) | ✅ Supported | URLProtocol + TurboModule |
| React Native iOS (Old Architecture) | ✅ Supported | URLProtocol + legacy bridge |
| Expo Development Build + Prebuild (Android + iOS) | ✅ Supported | Config plugin patches both platforms |
| Expo Go | ❌ Not supported | Native interception requires a dev build |
| iOS | 🚧 In progress | Not yet implemented end-to-end |

## Contributing

Expand Down
121 changes: 121 additions & 0 deletions example/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.8)
activesupport (7.2.3.1)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1, < 6)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.9.0)
public_suffix (>= 2.0.2, < 8.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (4.1.2)
claide (1.1.0)
cocoapods (1.15.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.15.2)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.1, < 3.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.15.2)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
netrc (~> 0.11)
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (2.1)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.3.3)
connection_pool (3.0.2)
drb (2.2.3)
escape (0.0.4)
ethon (0.18.0)
ffi (>= 1.15.0)
logger
ffi (1.17.4)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.9.0)
mutex_m
i18n (1.14.8)
concurrent-ruby (~> 1.0)
json (2.19.5)
logger (1.7.0)
minitest (5.27.0)
molinillo (0.8.0)
mutex_m (0.3.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
public_suffix (4.0.7)
rexml (3.4.4)
ruby-macho (2.5.1)
securerandom (0.4.1)
typhoeus (1.6.0)
ethon (>= 0.18.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.25.1)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (>= 3.3.6, < 4.0)

PLATFORMS
ruby

DEPENDENCIES
activesupport (>= 6.1.7.5, != 7.1.0)
benchmark
bigdecimal
cocoapods (>= 1.13, != 1.15.1, != 1.15.0)
concurrent-ruby (< 1.3.4)
logger
mutex_m
xcodeproj (< 1.26.0)

RUBY VERSION
ruby 3.2.0p0

BUNDLED WITH
2.5.11
Loading
Loading