NetLogger Development Guide
This skill provides essential procedural knowledge and architecture overview for maintaining and developing the NetLogger jailbreak tweak.
Core Architecture
NetLogger is an in-process network interceptor (Tweak) for iOS (specifically Dopamine rootless). It intercepts network requests and responses directly within the target application's process.
Key Components
Core Hooking (Tweak.x):
- Hooks
NSURLSessionConfiguration to inject NLURLProtocol.
- Hooks C-level SSL/TLS and POSIX socket functions (e.g.,
SSLWrite, SSLRead, send, recv) using MSHookFunction.
- Implements
applyMitmRules, applyMitmRequestRules, applyMitmResponseRules to intercept and manipulate JSON/Headers via a JavaScriptCore Engine or key-path matching.
Preference Bundle (netloggerprefs/):
- iOS Settings app integration using PreferenceLoader.
- Important: Detail Controllers (like
NLBlacklistController, NLMitmRulesController, NLLogDetailViewController) MUST subclass PSViewController (not UIViewController), implement loadView, and avoid manual view initialization in viewDidLoad to prevent doesNotRecognizeSelector: SIGABRT crashes in the Settings app.
- Localization (i18n): Supports English (
en.lproj) and Vietnamese (vi.lproj). Strings are managed via Localizable.strings and Root.strings and accessed using the NLLocalizedString macro in NLLocalization.h.
Sileo Depiction (docs/depictions/com.minh.netlogger.json):
- Uses Sileo Native Depiction format.
minVersion must be at least 0.4 to support Screenshots.
Build and Deployment Workflow
Always use the custom build script instead of manually running make package.
# Clean, compile (with DEBUG=0 FINALPACKAGE=1), package, and update apt repository hashes (MD5, SHA256)
./update_repo.sh
Git Workflow:
After a successful build, always commit the changes and push to the remote repository (GitHub Pages acts as the APT repository).
git add .
git commit -m "feat/fix: Description"
git push
Best Practices & Guidelines
1. Handling Settings UI (PreferenceLoader)
- NEVER subclass
UIViewController directly for screens launched from Root.plist or other preference cells. Always use <Preferences/PSViewController.h>.
- Keyboard Handling: For screens with text inputs at the bottom (e.g., MitM Rules), always implement
UIKeyboardWillShowNotification and UIKeyboardWillHideNotification to adjust the tableView.contentInset.
- Background Colors: When highlighting table cells in iOS 13+, restore the color to
[UIColor secondarySystemGroupedBackgroundColor] instead of nil to prevent transparency bugs in grouped tables.
2. JavaScriptCore Engine (MitM)
- The MitM engine uses
JSContext to evaluate user-provided JavaScript scripts.
- The payload is injected as a global variable named
body (Object if JSON, String if text).
- Always wrap JS evaluation in try-catch or use
JSContext.exceptionHandler to prevent user-provided scripts from crashing the host app.
3. Localization
- When adding new UI text in
netloggerprefs/, wrap strings in NLLocalizedString(@"Key", @"Fallback").
- Update both
netloggerprefs/Resources/en.lproj/Localizable.strings and netloggerprefs/Resources/vi.lproj/Localizable.strings.
4. Debugging
- Use
NSLog(@"[NetLogger] ...") for logging in Tweak.x. Use the Console app or oslog to view them.
- Ensure
DEBUG = 0 and FINALPACKAGE = 1 are set in the root Makefile before releasing to remove debug symbols and reduce .deb size.
1---2name: netlogger-dev3description: Expert guide and domain knowledge for developing, maintaining, and debugging the NetLogger jailbreak tweak project. Use this skill whenever the user asks to modify NetLogger, add features, or fix bugs.4---56# NetLogger Development Guide78This skill provides essential procedural knowledge and architecture overview for maintaining and developing the NetLogger jailbreak tweak.910## Core Architecture1112NetLogger is an in-process network interceptor (Tweak) for iOS (specifically Dopamine rootless). It intercepts network requests and responses directly within the target application's process.1314### Key Components151. **Core Hooking (`Tweak.x`)**:16 - Hooks `NSURLSessionConfiguration` to inject `NLURLProtocol`.17 - Hooks C-level SSL/TLS and POSIX socket functions (e.g., `SSLWrite`, `SSLRead`, `send`, `recv`) using `MSHookFunction`.18 - Implements `applyMitmRules`, `applyMitmRequestRules`, `applyMitmResponseRules` to intercept and manipulate JSON/Headers via a **JavaScriptCore Engine** or key-path matching.19202. **Preference Bundle (`netloggerprefs/`)**:21 - iOS Settings app integration using PreferenceLoader.22 - **Important**: Detail Controllers (like `NLBlacklistController`, `NLMitmRulesController`, `NLLogDetailViewController`) **MUST** subclass `PSViewController` (not `UIViewController`), implement `loadView`, and avoid manual view initialization in `viewDidLoad` to prevent `doesNotRecognizeSelector:` SIGABRT crashes in the Settings app.23 - **Localization (i18n)**: Supports English (`en.lproj`) and Vietnamese (`vi.lproj`). Strings are managed via `Localizable.strings` and `Root.strings` and accessed using the `NLLocalizedString` macro in `NLLocalization.h`.24253. **Sileo Depiction (`docs/depictions/com.minh.netlogger.json`)**:26 - Uses Sileo Native Depiction format.27 - `minVersion` must be at least `0.4` to support Screenshots.2829## Build and Deployment Workflow3031Always use the custom build script instead of manually running `make package`.3233```bash34# Clean, compile (with DEBUG=0 FINALPACKAGE=1), package, and update apt repository hashes (MD5, SHA256)35./update_repo.sh36```3738**Git Workflow:**39After a successful build, always commit the changes and push to the remote repository (GitHub Pages acts as the APT repository).40```bash41git add .42git commit -m "feat/fix: Description"43git push44```4546## Best Practices & Guidelines4748### 1. Handling Settings UI (PreferenceLoader)49- **NEVER** subclass `UIViewController` directly for screens launched from `Root.plist` or other preference cells. Always use `<Preferences/PSViewController.h>`.50- **Keyboard Handling**: For screens with text inputs at the bottom (e.g., MitM Rules), always implement `UIKeyboardWillShowNotification` and `UIKeyboardWillHideNotification` to adjust the `tableView.contentInset`.51- **Background Colors**: When highlighting table cells in iOS 13+, restore the color to `[UIColor secondarySystemGroupedBackgroundColor]` instead of `nil` to prevent transparency bugs in grouped tables.5253### 2. JavaScriptCore Engine (MitM)54- The MitM engine uses `JSContext` to evaluate user-provided JavaScript scripts.55- The payload is injected as a global variable named `body` (Object if JSON, String if text).56- Always wrap JS evaluation in try-catch or use `JSContext.exceptionHandler` to prevent user-provided scripts from crashing the host app.5758### 3. Localization59- When adding new UI text in `netloggerprefs/`, wrap strings in `NLLocalizedString(@"Key", @"Fallback")`.60- Update both `netloggerprefs/Resources/en.lproj/Localizable.strings` and `netloggerprefs/Resources/vi.lproj/Localizable.strings`.6162### 4. Debugging63- Use `NSLog(@"[NetLogger] ...")` for logging in `Tweak.x`. Use the Console app or `oslog` to view them.64- Ensure `DEBUG = 0` and `FINALPACKAGE = 1` are set in the root `Makefile` before releasing to remove debug symbols and reduce `.deb` size.