Files
daily-notification-plugin/doc/IOS_TEST_APP_SETUP_GUIDE.md
Server 5844b92e18 feat(ios): implement Phase 1 permission methods and fix build issues
Implement checkPermissionStatus() and requestNotificationPermissions()
methods for iOS plugin, matching Android functionality. Fix compilation
errors across plugin files and add comprehensive build/test infrastructure.

Key Changes:
- Add checkPermissionStatus() and requestNotificationPermissions() methods
- Fix 13+ categories of Swift compilation errors (type conversions, logger
  API, access control, async/await, etc.)
- Create DailyNotificationScheduler, DailyNotificationStorage,
  DailyNotificationStateActor, and DailyNotificationErrorCodes components
- Fix CoreData initialization to handle missing model gracefully for Phase 1
- Add iOS test app build script with simulator auto-detection
- Update directive with lessons learned from build and permission work

Build Status:  BUILD SUCCEEDED
Test App:  Ready for iOS Simulator testing

Files Modified:
- doc/directives/0003-iOS-Android-Parity-Directive.md (lessons learned)
- ios/Plugin/DailyNotificationPlugin.swift (Phase 1 methods)
- ios/Plugin/DailyNotificationModel.swift (CoreData fix)
- 11+ other plugin files (compilation fixes)

Files Added:
- ios/Plugin/DailyNotificationScheduler.swift
- ios/Plugin/DailyNotificationStorage.swift
- ios/Plugin/DailyNotificationStateActor.swift
- ios/Plugin/DailyNotificationErrorCodes.swift
- scripts/build-ios-test-app.sh
- scripts/setup-ios-test-app.sh
- test-apps/ios-test-app/ (full test app)
- Multiple Phase 1 documentation files
2025-11-13 05:14:24 -08:00

211 lines
4.2 KiB
Markdown

# iOS Test App Setup Guide
**Status:** 📋 **SETUP REQUIRED**
**Objective:** Create iOS test app for Phase 1 testing
---
## Problem
The iOS test app (`test-apps/ios-test-app/`) does not exist yet. This guide will help you create it.
---
## Quick Setup
### Option 1: Automated Setup (Recommended)
Run the setup script:
```bash
./scripts/setup-ios-test-app.sh
```
This will:
- Create basic directory structure
- Copy HTML from Android test app
- Create `capacitor.config.json` and `package.json`
- Set up basic files
### Option 2: Manual Setup
Follow the steps below to create the iOS test app manually.
---
## Manual Setup Steps
### Step 1: Create Directory Structure
```bash
cd test-apps
mkdir -p ios-test-app/App/App/Public
cd ios-test-app
```
### Step 2: Initialize Capacitor
```bash
# Create package.json
cat > package.json << 'EOF'
{
"name": "ios-test-app",
"version": "1.0.0",
"description": "iOS test app for DailyNotification plugin",
"scripts": {
"sync": "npx cap sync ios",
"open": "npx cap open ios"
},
"dependencies": {
"@capacitor/core": "^5.0.0",
"@capacitor/ios": "^5.0.0"
}
}
EOF
# Install dependencies
npm install
# Add iOS platform
npx cap add ios
```
### Step 3: Copy HTML from Android Test App
```bash
# Copy HTML file
cp ../android-test-app/app/src/main/assets/public/index.html App/App/Public/index.html
```
### Step 4: Configure Capacitor
Create `capacitor.config.json`:
```json
{
"appId": "com.timesafari.dailynotification.test",
"appName": "DailyNotification Test App",
"webDir": "App/App/Public",
"server": {
"iosScheme": "capacitor"
},
"plugins": {
"DailyNotification": {
"enabled": true
}
}
}
```
### Step 5: Configure Info.plist
Edit `App/App/Info.plist` and add:
```xml
<!-- Background Task Identifiers -->
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.timesafari.dailynotification.fetch</string>
<string>com.timesafari.dailynotification.notify</string>
</array>
<!-- Background Modes -->
<key>UIBackgroundModes</key>
<array>
<string>background-fetch</string>
<string>background-processing</string>
<string>remote-notification</string>
</array>
<!-- Notification Permissions -->
<key>NSUserNotificationsUsageDescription</key>
<string>This app uses notifications to deliver daily updates and reminders.</string>
```
### Step 6: Link Plugin
The plugin needs to be accessible. Options:
**Option A: Local Development (Recommended)**
- Ensure plugin is at `../../ios/Plugin/`
- Capacitor will auto-detect it during sync
**Option B: Via npm**
- Install plugin: `npm install ../../`
- Capacitor will link it automatically
### Step 7: Sync Capacitor
```bash
npx cap sync ios
```
### Step 8: Build and Run
```bash
# Use build script
../../scripts/build-ios-test-app.sh --simulator
# Or open in Xcode
npx cap open ios
# Then press Cmd+R in Xcode
```
---
## Troubleshooting
### Issue: "No Xcode workspace or project found"
**Solution:** Run `npx cap add ios` first to create the Xcode project.
### Issue: Plugin not found
**Solution:**
1. Ensure plugin exists at `../../ios/Plugin/`
2. Run `npx cap sync ios`
3. Check `App/App/capacitor.plugins.json` contains DailyNotification entry
### Issue: BGTask not running
**Solution:**
1. Verify Info.plist has `BGTaskSchedulerPermittedIdentifiers`
2. Check task registered in AppDelegate
3. Use simulator-only LLDB command to manually trigger (see testing guide)
### Issue: Build failures
**Solution:**
1. Run `pod install` in `App/` directory
2. Clean build folder in Xcode (Cmd+Shift+K)
3. Verify Capacitor plugin path
---
## Verification Checklist
After setup, verify:
- [ ] `test-apps/ios-test-app/` directory exists
- [ ] `App.xcworkspace` or `App.xcodeproj` exists
- [ ] `App/App/Public/index.html` exists
- [ ] `capacitor.config.json` exists
- [ ] `Info.plist` has BGTask identifiers
- [ ] Plugin loads in test app
- [ ] Build script works: `./scripts/build-ios-test-app.sh --simulator`
---
## References
- **Requirements:** `doc/test-app-ios/IOS_TEST_APP_REQUIREMENTS.md`
- **Testing Guide:** `doc/IOS_PHASE1_TESTING_GUIDE.md`
- **Build Script:** `scripts/build-ios-test-app.sh`
- **Setup Script:** `scripts/setup-ios-test-app.sh`
---
**Status:** 📋 **SETUP REQUIRED**
**Last Updated:** 2025-01-XX