proofmode 0.9.0

Capture, share, and preserve verifiable photos and videos
Documentation
# ProofMode iOS Example App

This is a complete iOS example application demonstrating the usage of ProofMode-Rust library for generating and verifying cryptographic proofs for photos.

## Features

- **Photo Capture**: Take photos directly from the camera or select from photo library
- **Proof Generation**: Generate cryptographic proofs with metadata including:
  - SHA-256 hash of the image
  - Location information (optional)
  - Device information
  - Network information
  - PGP digital signature
- **Proof Verification**: Verify existing proofs and check their validity
- **Proof Management**: View, share, and export proof bundles
- **Privacy Controls**: Control which metadata to include in proofs

## Requirements

- **macOS**: Required for building the XCFramework
- **iOS 16.0+**: Target deployment version
- **Xcode 15.0+**: Development environment
- **Swift 5.9+**: Programming language version

## Quick Setup

### Option 1: Automated Setup (Recommended)

Run the automated setup script from the project root:

```bash
# This will build everything needed for iOS
./scripts/setup-ios.sh
```

If you're on macOS, this will:
1. Install iOS targets
2. Build the Rust library for all iOS architectures
3. Generate Swift bindings
4. Create the XCFramework
5. Set up the Xcode project

### Option 2: Manual Setup

#### Step 1: Build the Framework

From the project root directory:

```bash
# Install iOS build script
chmod +x scripts/ios/build-framework.sh

# Build XCFramework (macOS only)
./scripts/ios/build-framework.sh
```

#### Step 2: Setup Xcode Project

```bash
# Setup Xcode project with framework
./scripts/ios/setup-xcode-project.sh
```

#### Step 3: Open and Configure Xcode Project

1. Open the project:
   ```bash
   cd ios-example
   open ProofModeExample.xcodeproj
   ```

2. Add the framework to your project:
   - Select the ProofModeExample project in the navigator
   - Go to the ProofModeExample target's "General" tab
   - In "Frameworks, Libraries, and Embedded Content":
     - Click the "+" button
     - Click "Add Other..." → "Add Files..."
     - Navigate to and select `ProofMode.xcframework`
     - Choose "Embed & Sign"

3. Add Swift bindings to your project:
   - Right-click on the ProofModeExample group in Xcode
   - Select "Add Files to ProofModeExample"
   - Navigate to `ProofModeExample/ProofModeBindings/`
   - Select all `.swift` files and add them

4. Configure code signing:
   - Select your development team
   - Update the bundle identifier if needed

5. Build and run (⌘+R)

## Project Structure

```
ProofModeExample/
├── ProofModeExampleApp.swift    # Main app entry point
├── Models/
│   └── Proof.swift              # Proof data model
├── Views/
│   ├── ContentView.swift        # Main tab view
│   ├── CameraView.swift         # Camera capture interface
│   ├── ImagePicker.swift        # Photo library picker
│   ├── ProofListView.swift      # List of generated proofs
│   └── ProofDetailView.swift    # Detailed proof information
├── ViewModels/
│   └── ProofViewModel.swift     # Main business logic
├── Services/
│   ├── ProofModeService.swift   # ProofMode library wrapper
│   └── PermissionService.swift  # Permission handling
├── Resources/
│   └── Assets.xcassets          # App assets
└── ProofModeBindings/           # Generated Swift bindings
    └── *.swift                  # UniFFI generated files
```

## Usage

### Generating a Proof

1. Launch the app and go to the "Generate" tab
2. Choose to either:
   - Tap "Take Photo" to capture a new photo
   - Tap "Choose from Library" to select an existing photo
3. The app will automatically:
   - Calculate the SHA-256 hash
   - Collect device and location metadata (if permitted)
   - Generate a PGP signature
   - Save the proof bundle

### Verifying a Proof

1. Go to the "Verify" tab
2. Select a proof from the list
3. View detailed information including:
   - Original image
   - Cryptographic hash
   - Location data (if included)
   - Device information
   - Digital signature
4. Tap "Verify Proof" to validate the signature

## Development Notes

### Integrating with Real ProofMode Library

The example app initially uses mock implementations. To integrate with the actual ProofMode-Rust library:

1. Ensure the XCFramework is properly added to your project
2. In `ProofModeService.swift`, replace mock implementations with actual ProofMode calls
3. Handle errors and progress callbacks as needed
4. Test thoroughly on both simulator and device

### Permissions

The app requires these permissions (requested only when needed):
- **Camera**: `NSCameraUsageDescription`
- **Photo Library**: `NSPhotoLibraryUsageDescription`  
- **Location**: `NSLocationWhenInUseUsageDescription`

### Architecture Notes

- Uses SwiftUI for the user interface
- Follows MVVM architecture pattern
- Implements proper error handling and user feedback
- Supports both simulator and device builds
- Uses async/await for asynchronous operations

## Troubleshooting

### Build Issues

**"No such module 'ProofMode'"**
- Ensure the XCFramework is properly added to your project
- Check that it's set to "Embed & Sign"
- Clean build folder (⌘+Shift+K) and rebuild

**"dyld: Library not loaded"**
- Ensure the framework is embedded, not just linked
- Check that the framework is built for the correct architecture

**"Missing Swift bindings"**
- Ensure Swift binding files are added to your Xcode project
- Check that the files are included in the target membership

### Runtime Issues

**"ProofMode not initialized"**
- Call `proofMode.initialize()` before using other methods
- Check that initialization completes successfully

**"Permission denied"**
- Ensure proper usage descriptions in Info.plist
- Handle permission requests gracefully in your code

## Contributing

This example app demonstrates core ProofMode functionality. Contributions are welcome for:
- Additional verification methods
- Enhanced UI/UX
- Better error handling
- Performance optimizations
- Additional metadata types

## License

This example app is part of the ProofMode-Rust project and follows the same Apache 2.0 license terms.