docs(ios): add comprehensive console debugging guide
Created detailed guide for viewing console logs: Console Debugging Guide: - Method 1: Safari Web Inspector (JavaScript console) - recommended - Method 2: Xcode Console (Native Swift logs) - Method 3: Terminal commands (quick log viewing) Guide Includes: - Step-by-step instructions for each method - What logs you'll see in each method - Troubleshooting common issues - Example debugging session - Quick reference table Access Methods: - Safari Web Inspector: Best for JavaScript/plugin debugging - Xcode Console: Best for native Swift debugging - Terminal: Best for quick checks and filtering Result: Developers can now easily debug permission issues and plugin calls
This commit is contained in:
162
test-apps/ios-test-app/docs/CONSOLE_DEBUGGING.md
Normal file
162
test-apps/ios-test-app/docs/CONSOLE_DEBUGGING.md
Normal file
@@ -0,0 +1,162 @@
|
||||
# Console Debugging Guide for iOS Test App
|
||||
|
||||
**Author**: Matthew Raymer
|
||||
**Date**: November 11, 2025
|
||||
**Version**: 1.0.0
|
||||
|
||||
## Overview
|
||||
|
||||
This guide explains how to view console logs from the iOS test app, including both JavaScript (WebView) and native Swift logs.
|
||||
|
||||
## Method 1: Safari Web Inspector (JavaScript Console) ⭐ Recommended
|
||||
|
||||
This is the best way to see JavaScript console.log() messages and debug plugin calls.
|
||||
|
||||
### Step 1: Enable Web Inspector on Simulator
|
||||
|
||||
1. Open **Settings** app on the iOS Simulator
|
||||
2. Navigate to **Safari** → **Advanced**
|
||||
3. Toggle **"Web Inspector"** to ON
|
||||
|
||||
### Step 2: Enable Develop Menu in Safari (Mac)
|
||||
|
||||
1. Open **Safari** on your Mac
|
||||
2. Go to **Safari** → **Settings** (or **Preferences**)
|
||||
3. Click **"Advanced"** tab
|
||||
4. Check **"Show Develop menu in menu bar"**
|
||||
|
||||
### Step 3: Connect to Your App
|
||||
|
||||
1. Make sure your app is running in the simulator
|
||||
2. In Safari menu bar: **Develop** → **[Your Simulator Name]** → **[Your App Name]**
|
||||
- Example: **Develop** → **iPhone 17 Pro - iOS 26.0** → **DailyNotification Test App**
|
||||
3. This opens the Web Inspector window
|
||||
|
||||
### Step 4: View Console
|
||||
|
||||
1. Click the **"Console"** tab in Web Inspector
|
||||
2. You'll see all JavaScript `console.log()`, `console.error()`, etc. messages
|
||||
3. Filter by typing in the search box (e.g., "permission", "DNP", "error")
|
||||
|
||||
### What You'll See
|
||||
|
||||
- `🔐 checkPermissions called`
|
||||
- `🔐 Plugin available: true/false`
|
||||
- `🔐 checkPermissionStatus method: function/undefined`
|
||||
- `✅ Permission status result:` (if successful)
|
||||
- `❌ Error:` (if failed)
|
||||
|
||||
## Method 2: Xcode Console (Native Swift Logs)
|
||||
|
||||
This shows native Swift `print()`, `NSLog()`, and `os_log()` messages.
|
||||
|
||||
### Steps
|
||||
|
||||
1. Open **Xcode**
|
||||
2. Go to **Window** → **Devices and Simulators** (or press `Cmd+Shift+2`)
|
||||
3. Select your simulator from the left sidebar
|
||||
4. Click **"Open Console"** button at the bottom
|
||||
5. Filter by typing in the search box:
|
||||
- `DNP-PLUGIN` - All plugin logs
|
||||
- `App` - All app logs
|
||||
- `permission` - Permission-related logs
|
||||
|
||||
### What You'll See
|
||||
|
||||
- `DNP-PLUGIN: Checking permission status`
|
||||
- `DNP-PLUGIN: Permission status: notifications=true, exactAlarm=true...`
|
||||
- `DNP-PLUGIN: Requesting notification permissions`
|
||||
|
||||
## Method 3: Terminal (Command Line)
|
||||
|
||||
For quick log viewing without opening Xcode or Safari.
|
||||
|
||||
### View All App Logs
|
||||
|
||||
```bash
|
||||
xcrun simctl spawn booted log stream --predicate 'process == "App"' --level info
|
||||
```
|
||||
|
||||
### View Plugin Logs Only
|
||||
|
||||
```bash
|
||||
xcrun simctl spawn booted log stream --predicate 'subsystem == "com.timesafari.dailynotification"' --level info
|
||||
```
|
||||
|
||||
### View Permission-Related Logs
|
||||
|
||||
```bash
|
||||
xcrun simctl spawn booted log stream --predicate 'process == "App" OR subsystem == "com.timesafari.dailynotification"' --level info | grep -iE "DNP|permission|error|check"
|
||||
```
|
||||
|
||||
### View Recent Logs (Last 10 Minutes)
|
||||
|
||||
```bash
|
||||
xcrun simctl spawn booted log show --predicate 'process == "App" OR subsystem == "com.timesafari.dailynotification"' --last 10m --style compact | grep -iE "DNP|permission"
|
||||
```
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### JavaScript Console (Safari Web Inspector)
|
||||
- **Best for**: Debugging JavaScript/TypeScript code, plugin method calls
|
||||
- **Shows**: `console.log()`, `console.error()`, promise results
|
||||
- **Access**: Safari → Develop → [Simulator] → [App] → Console tab
|
||||
|
||||
### Native Console (Xcode)
|
||||
- **Best for**: Debugging Swift code, native plugin implementation
|
||||
- **Shows**: `print()`, `NSLog()`, `os_log()` messages
|
||||
- **Access**: Xcode → Window → Devices and Simulators → Open Console
|
||||
|
||||
### Terminal Logs
|
||||
- **Best for**: Quick checks, filtering, automation
|
||||
- **Shows**: System logs, app logs, plugin logs
|
||||
- **Access**: Terminal commands (see above)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Develop menu not showing in Safari"
|
||||
- Make sure you enabled "Show Develop menu in menu bar" in Safari settings
|
||||
- Restart Safari if needed
|
||||
|
||||
### "No devices in Develop menu"
|
||||
- Make sure the simulator is running
|
||||
- Make sure the app is running in the simulator
|
||||
- Try restarting Safari
|
||||
|
||||
### "Web Inspector shows blank console"
|
||||
- Make sure Web Inspector is enabled in simulator Settings → Safari → Advanced
|
||||
- Try refreshing the Web Inspector (close and reopen)
|
||||
- Check that JavaScript is enabled in the app
|
||||
|
||||
### "No logs in Xcode Console"
|
||||
- Make sure you selected the correct simulator
|
||||
- Check that the app is actually running
|
||||
- Try filtering by process name or subsystem
|
||||
|
||||
## Example Debugging Session
|
||||
|
||||
1. **Open Safari Web Inspector** (Method 1)
|
||||
2. **Click "Check Permissions" button** in the app
|
||||
3. **Watch the Console tab** for:
|
||||
```
|
||||
🔐 checkPermissions called
|
||||
🔐 Plugin available: true
|
||||
🔐 checkPermissionStatus method: function
|
||||
🔐 Calling checkPermissionStatus...
|
||||
🔐 Promise returned: Promise {<pending>}
|
||||
✅ Permission status result: {notificationsEnabled: false, ...}
|
||||
```
|
||||
4. **If you see errors**, check:
|
||||
- Is the plugin registered? (should see "Plugin available: true")
|
||||
- Is the method a function? (should see "function")
|
||||
- Does it return a promise? (should see "Promise")
|
||||
- What's the error message?
|
||||
|
||||
## Next Steps
|
||||
|
||||
After checking the console:
|
||||
- If you see **"Plugin available: false"** → Plugin registration issue
|
||||
- If you see **"checkPermissionStatus method: undefined"** → Method not registered
|
||||
- If you see **"Permission check timed out"** → Promise never resolved (check native logs)
|
||||
- If you see **error messages** → Check the error details in console
|
||||
|
||||
Reference in New Issue
Block a user