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
This commit is contained in:
Server
2025-11-13 05:14:24 -08:00
parent 2d84ae29ba
commit 5844b92e18
61 changed files with 9676 additions and 356 deletions

View File

@@ -115,25 +115,61 @@ extension History: Identifiable {
}
// MARK: - Persistence Controller
// Phase 2: CoreData integration for advanced features
// Phase 1: Stubbed out - CoreData model not yet created
class PersistenceController {
static let shared = PersistenceController()
// Lazy initialization to prevent Phase 1 errors
private static var _shared: PersistenceController?
static var shared: PersistenceController {
if _shared == nil {
_shared = PersistenceController()
}
return _shared!
}
let container: NSPersistentContainer
let container: NSPersistentContainer?
private var initializationError: Error?
init(inMemory: Bool = false) {
container = NSPersistentContainer(name: "DailyNotificationModel")
// Phase 1: CoreData model doesn't exist yet, so we'll handle gracefully
// Phase 2: Will create DailyNotificationModel.xcdatamodeld
var tempContainer: NSPersistentContainer? = nil
if inMemory {
container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")
}
container.loadPersistentStores { _, error in
if let error = error as NSError? {
fatalError("Core Data error: \(error), \(error.userInfo)")
do {
tempContainer = NSPersistentContainer(name: "DailyNotificationModel")
if inMemory {
tempContainer?.persistentStoreDescriptions.first?.url = URL(fileURLWithPath: "/dev/null")
}
var loadError: Error? = nil
tempContainer?.loadPersistentStores { _, error in
if let error = error as NSError? {
loadError = error
print("DNP-PLUGIN: CoreData model not found (Phase 1 - expected). Error: \(error.localizedDescription)")
print("DNP-PLUGIN: CoreData features will be available in Phase 2")
}
}
if let error = loadError {
self.initializationError = error
self.container = nil
} else {
tempContainer?.viewContext.automaticallyMergesChangesFromParent = true
self.container = tempContainer
}
} catch {
print("DNP-PLUGIN: Failed to initialize CoreData container: \(error.localizedDescription)")
self.initializationError = error
self.container = nil
}
container.viewContext.automaticallyMergesChangesFromParent = true
}
/**
* Check if CoreData is available (Phase 2+)
*/
var isAvailable: Bool {
return container != nil && initializationError == nil
}
}