diff --git a/doc/test-app-ios/IOS_PREFETCH_TESTING.md b/doc/test-app-ios/IOS_PREFETCH_TESTING.md index de4f51d..c7689c1 100644 --- a/doc/test-app-ios/IOS_PREFETCH_TESTING.md +++ b/doc/test-app-ios/IOS_PREFETCH_TESTING.md @@ -9,7 +9,7 @@ **Last Updated:** 2025-11-15 **Status:** 🎯 **ACTIVE** - Testing guide for Phase 1+ implementation -**Note:** This guide assumes the iOS test app is implemented as described in `doc/test-app-ios/IOS_TEST_APP_REQUIREMENTS.md`. +**Note:** This guide assumes the iOS test app is implemented as described in `doc/test-app-ios/IOS_TEST_APP_REQUIREMENTS.md`. The test app is located at `test-apps/ios-test-app/`. **Glossary:** See `doc/test-app-ios/IOS_PREFETCH_GLOSSARY.md` for terminology definitions. @@ -112,11 +112,18 @@ Verify that the **iOS prefetch path actually runs**: Quick validation checklist (each step links to log verification): -1. Build test app (per `IOS_TEST_APP_REQUIREMENTS.md`) +1. Build test app (per `IOS_TEST_APP_REQUIREMENTS.md`): + ```bash + cd test-apps/ios-test-app + # Or from repo root: ./scripts/build-ios-test-app.sh --simulator + ``` 2. Run on iOS Simulator 3. Schedule notification 5 minutes in future → **See Log Checklist → Notification Scheduled** 4. Background app (Home button / Cmd+Shift+H) -5. Xcode → Debug → Simulate Background Fetch → **See Log Checklist → BGTask Fired** +5. **Trigger BGTask** (see Step 4 below for methods): + - **Recommended:** Use LLDB command in Xcode console (app must be running) + - **Alternative:** Stop app, then use Xcode → Debug → Simulate Background Fetch + - **See Log Checklist → BGTask Fired** 6. Confirm logs show: Registration → Scheduling → BGTask handler → Fetch success → Task completed 7. Wait for notification time or manually trigger → **See Log Checklist → Notification Delivery** 8. Verify notification uses cached content (check logs for `[DNP-FETCH] Found cached content`) → **See Log Checklist → Notification Delivery** @@ -224,12 +231,29 @@ Add structured logs at key points: ### 4. Simulate Background Fetch -With app running: +**Important:** Xcode's "Simulate Background Fetch" menu item only appears when the app is **NOT running**. When the app is running, use the LLDB command method below. -1. **Background the app** (Home button / Cmd+Shift+H) +**Method 1: LLDB Command (Recommended when app is running)** + +1. **Background the app** (Home button / Cmd+Shift+H in simulator) +2. **Open Xcode Debug Console** (View → Debug Area → Activate Console, or press Cmd+Shift+Y) +3. **In LLDB console, paste and execute:** + ```bash + e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.timesafari.dailynotification.fetch"] + ``` +4. Press Enter + +**Method 2: Xcode Menu (Only when app is NOT running)** + +1. **Stop the app** (Cmd+.) 2. In Xcode menu: - **Debug → Simulate Background Fetch** or - **Debug → Simulate Background Refresh** +3. This will launch the app and trigger the background fetch + +**Method 3: Test App UI Button (If implemented)** + +- Use test app UI button: "Simulate BGTask Now" (if available in test app) **Expected logs (in order):** ``` @@ -243,14 +267,10 @@ With app running: **See Sample Prefetch Response & Mapping below for expected API response structure.** -**Copy-Paste Commands:** - -```bash -# In Xcode LLDB console (simulator only): -e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.timesafari.dailynotification.fetch"] - -# Or use test app UI button: "Simulate BGTask Now" -``` +**Troubleshooting:** +- If LLDB command doesn't work, ensure the app is backgrounded first +- If you see "Simulate Background Fetch" in menu when app is running, it may be a different Xcode version - try the LLDB method anyway +- Verify BGTask identifier matches exactly: `com.timesafari.dailynotification.fetch` ### 5. Trigger or Wait for Notification