compilation_errors_fix_plan.md 4.92 KB

Compilation Errors Fix Plan

Overview

After fixing the DatabaseManager compilation errors, several new compilation errors appeared in other files. This document outlines the errors and the planned fixes.

Current Compilation Errors

1. WarplySDK.swift (8 errors)

Error Details:

  • Line 2585: Value of type 'NetworkService' has no member 'setTokens'
  • Lines 2611, 2612: 'async' call in a function that does not support concurrency in constructCampaignParams(_ campaign:)
  • Lines 2641, 2642: 'async' call in a function that does not support concurrency in constructCampaignParams(campaign:isMap:)
  • Lines 2611, 2612, 2641, 2642: Call can throw, but it is not marked with 'try' and the error is not handled

Root Cause:

  • The code is trying to call networkService.setTokens() which doesn't exist
  • The code is calling async methods getAccessToken() and getRefreshToken() from synchronous functions
  • The constructCampaignParams methods are synchronous but trying to call async NetworkService methods

Planned Fix:

  • Option A: Make constructCampaignParams methods async
  • Option B: Use DatabaseManager to get tokens synchronously (CHOSEN)
  • Remove the non-existent setTokens() call
  • Replace async NetworkService calls with synchronous DatabaseManager calls

2. DatabaseConfiguration.swift (3 errors)

Error Details:

  • Line 237: Cannot assign to property: 'fileProtection' is a get-only property
  • Line 237: Cannot assign value of type 'FileProtectionType' to type 'URLFileProtection?'
  • Line 239: Cannot use mutating member on immutable value: 'fileURL' is a 'let' constant

Root Cause:

  • The code is trying to set file protection using URLResourceValues incorrectly
  • fileProtection property is read-only
  • Type mismatch between FileProtectionType and URLFileProtection
  • Trying to mutate an immutable URL

Planned Fix:

  • Use FileManager.setAttributes() approach instead of URLResourceValues
  • Use the correct file protection API for iOS

3. WarplyConfiguration.swift (1 warning)

Error Details:

  • Line 40: Immutable property will not be decoded because it is declared with an initial value which cannot be overwritten

Root Cause:

  • The frameworkVersion property has an initial value and is immutable, so Codable can't decode it

Planned Fix:

  • Either make the property mutable (var) or exclude it from Codable using CodingKeys

Implementation Strategy

Phase 1: Examine NetworkService

  1. Check NetworkService.swift to understand available token management methods
  2. Identify the correct method to replace setTokens()

Phase 2: Fix WarplySDK Token Handling

  1. Remove the non-existent setTokens() call
  2. Replace async NetworkService calls with synchronous DatabaseManager calls
  3. Update constructCampaignParams methods to use DatabaseManager

Phase 3: Fix DatabaseConfiguration File Protection

  1. Replace URLResourceValues approach with FileManager.setAttributes()
  2. Use correct iOS file protection types
  3. Handle URL mutability properly

Phase 4: Fix WarplyConfiguration Codable

  1. Add CodingKeys enum to exclude frameworkVersion from decoding
  2. Keep the property immutable with initial value

Security Considerations

Two-Layer Security Approach:

  1. Token Encryption (already working):

    • Encrypts token data before storing in database
    • Uses FieldEncryption.swift
    • Protects token content
  2. File Protection (to be fixed):

    • Sets iOS file protection on database file
    • Prevents file access when device is locked
    • Additional security layer

Expected Outcome

  • All compilation errors resolved
  • Maintain existing functionality
  • Preserve both token encryption and file protection security features
  • Clean, maintainable code structure

Files Modified

  1. SwiftWarplyFramework/SwiftWarplyFramework/Core/WarplySDK.swift

    • Fixed updateRefreshToken() method to use DatabaseManager instead of non-existent setTokens()
    • Fixed constructCampaignParams() methods to use synchronous token access from DatabaseManager
    • Replaced async NetworkService calls with synchronous DatabaseManager calls
  2. SwiftWarplyFramework/SwiftWarplyFramework/Configuration/DatabaseConfiguration.swift

    • Fixed applyFileProtection() method to use FileManager.setAttributes() instead of URLResourceValues
    • Resolved read-only property and type mismatch issues
  3. SwiftWarplyFramework/SwiftWarplyFramework/Configuration/WarplyConfiguration.swift

    • Added CodingKeys enum to exclude frameworkVersion from Codable encoding/decoding
    • Resolved immutable property warning

Status: COMPLETED ✅

All compilation errors have been fixed. The framework should now compile successfully with:

  • Proper token management through DatabaseManager
  • Working file protection for database security
  • Clean Codable implementation for configuration

Generated: 26/06/2025, 3:48 pm Updated: 26/06/2025, 3:52 pm