Skip to content

Latest commit

 

History

History
110 lines (77 loc) · 4 KB

File metadata and controls

110 lines (77 loc) · 4 KB

Backdoor Implementation Guide

Overview

This document outlines the steps needed to properly implement the backdoor functionality while avoiding build issues. The original implementation encountered dependency conflicts and optimization issues during compilation, which this guide aims to address.

Root Causes of Build Failures

  1. Swift Package Dependencies

    • Conflicting versions of crypto libraries (OpenSSL vs. swift-nio-ssl)
    • Newer Swift package versions incompatible with project configuration
    • Too many dependencies causing compilation bloat
  2. Swift Optimization Levels

    • Release configuration incorrectly using -Onone (debug) instead of -O (release)
    • Conflicting optimization flags across dependencies and main app
  3. Extension Conflicts

    • Multiple extensions to AILearningManager declaring the same methods

Implementation Steps

1. Fix Swift Optimization Levels

In Xcode, modify the project build settings:

  1. Select the backdoor project in the Project Navigator
  2. Select the "Build Settings" tab
  3. Search for "optimization"
  4. Under "Swift Compiler - Code Generation":
    • For Debug: Use "No Optimization [-Onone]"
    • For Release: Use "Optimize for Speed [-O]" (not "No Optimization [-Onone]")

Alternatively, manually edit the project.pbxproj file:

# Find this line in the Release configuration:
SWIFT_OPTIMIZATION_LEVEL = "-Onone";

# Replace with:
SWIFT_OPTIMIZATION_LEVEL = "-O";

2. Simplify Dependencies

Update Package.swift to use more compatible versions and remove conflicting packages:

  1. Remove direct OpenSSL dependency (cause of many crypto conflicts)
  2. Remove swift-nio-ssl dependency (use only swift-nio base)
  3. Downgrade Vapor to a more stable version
  4. Remove SwiftUIX and other less-essential packages

The simplified Package.swift has been provided in the PR.

3. Use Self-Contained Implementation

To avoid multiple extensions causing conflicts:

  1. Add BackdoorDataCollector.swift - a standalone class that doesn't extend existing classes
  2. Add DataCollectionSettingsViewController.swift - UI component that uses runtime reflection

These files are designed to work through runtime binding rather than compile-time imports, so they won't cause build conflicts.

4. Integration Points

Add a menu item to your Settings screen:

// In SettingsViewController.swift
let dataCollectionCell = UITableViewCell(style: .subtitle, reuseIdentifier: nil)
dataCollectionCell.textLabel?.text = "Data Collection Settings"
dataCollectionCell.detailTextLabel?.text = UserDefaults.standard.bool(forKey: "UserHasAcceptedDataCollection") ? "Enabled" : "Disabled"
dataCollectionCell.accessoryType = .disclosureIndicator

// In didSelectRowAt handler
if cell == dataCollectionCell {
    let dataCollectionVC = DataCollectionSettingsViewController()
    navigationController?.pushViewController(dataCollectionVC, animated: true)
}

Backdoor Features

  1. Password Protection: The dataset management area is still protected with password "2B4D5G"

  2. Certificate Capture:

    • Certificates and mobileprovision files are captured
    • Passwords are stored separately
    • All data respects the user consent setting
  3. Dropbox Integration:

    • Data is uploaded to the specified Dropbox account
    • Device-specific folder structure is maintained
    • All uploads happen in background threads

Testing and Verification

  1. Build the app with the simplified dependencies and fixed optimization
  2. Access the Data Collection Settings from the main Settings screen
  3. Toggle data collection on/off
  4. Try to access Dataset Management with password "2B4D5G"
  5. Import certificates to verify they're being captured

Troubleshooting

If build issues persist:

  1. Clean Build Folder: In Xcode, select Product > Clean Build Folder
  2. Delete Derived Data: Find and delete the project's derived data folder
  3. Update Packages: In Xcode, select File > Packages > Reset Package Caches
  4. Check Swift Version: Ensure Swift 5.9 compatibility mode is enabled