lame

Project Structure

This document explains what each file is for and why it exists.

Repository Tree

Lame/
  LameApp.swift
  ContentView.swift

  — iPhone (ImageCaptureCore) —
  DeviceManager.swift
  MediaFile.swift
  FileSystemItem.swift
  MediaGridView.swift
  MediaItemView.swift
  FileBrowserView.swift

  — Android (libmtp) —
  MTPBridge.swift
  AndroidMediaFile.swift
  AndroidDeviceManager.swift
  AndroidMediaGridView.swift
  AndroidFileBrowserView.swift

  — Shared —
  SizeRangeFilter.swift
  SortOptions.swift
  AppError.swift

  Assets.xcassets/
Lame.xcodeproj/
docs/
  Android-Support.md      ← new; covers approach, limitations, future options
  Architecture.md
  …

Source Files

LameApp.swift

This is the application entry point.

It creates the single shared DeviceManager and injects it into the SwiftUI environment so child views can read it.

ContentView.swift

This is the window-level layout.

It creates the two-column structure:

DeviceManager.swift

This is the most important non-UI file in the app.

It handles:

If you want to understand how the app talks to the iPhone, this is the file to read.

MediaFile.swift

This is a wrapper around ICCameraFile.

It exists because raw framework objects are not convenient for SwiftUI rendering. The wrapper adds:

MediaGridView.swift

This is the main interface users work with.

It manages:

It does not own device communication. It asks DeviceManager to perform those operations.

MediaItemView.swift

This is one grid cell.

It displays:

SortOptions.swift

This file contains small enums that define sorting choices. It is pure value logic and intentionally simple.

SizeRangeFilter.swift

This file contains two related things:

The filter supports:

AppError.swift

This centralizes app-specific error messages and lets the rest of the code use typed errors instead of ad hoc strings.


Android Source Files

These files implement Android MTP device support. They depend on libmtp being installed via Homebrew. For a detailed explanation of the design decisions, see docs/Android-Support.md.

MTPBridge.swift

This is the subprocess interface for libmtp.

It is a Swift actor that serialises all calls to the libmtp command-line tools (mtp-detect, mtp-files, mtp-thumb, mtp-getfile, mtp-delfile). The actor keyword guarantees that only one MTP operation runs at a time, which the MTP protocol requires.

The file also contains the output parsers that turn text from mtp-files into MTPFileInfo value types.

AndroidMediaFile.swift

This is the Android equivalent of MediaFile.swift.

It wraps an MTPFileInfo value type and adds SwiftUI observation support, per-item thumbnail state, and formatted display values. It also conforms to RangeFilterMatchable so the same filter panel used for iPhones works for Android files without modification.

AndroidDeviceManager.swift

This is the Android equivalent of DeviceManager.swift.

It manages:

AndroidMediaGridView.swift

This is the Android equivalent of MediaGridView.swift.

It provides the same photo and video grid with search, sort, size and date filtering, pinch-to-zoom, multi-select, and delete. It reads from AndroidDeviceManager instead of DeviceManager.

The file also contains AndroidMediaItemView, which is the single-cell component for the Android grid.

AndroidFileBrowserView.swift

This is the Android equivalent of FileBrowserView.swift.

It provides a folder-tree browser showing the complete MTP file system. Folder navigation is instant because AndroidDeviceManager builds the entire parent-child tree in memory during enumeration. Double-clicking a folder pushes it onto the breadcrumb stack.


Shared Source Files

These files serve both the iPhone and Android paths.

SizeRangeFilter.swift

This file now contains three things:

SortOptions.swift

Unchanged. The same SortField and SortOrder enums are used by both MediaGridView and AndroidMediaGridView.

Xcode Project Files

Lame.xcodeproj

This directory stores the Xcode project definition, build settings, target configuration, and workspace metadata.

Most application logic is not here. New contributors usually only touch this area when:

Asset Catalog

Assets.xcassets

This stores app icons and other visual assets managed by Xcode’s asset system.

Separation Of Concerns Summary

A quick mental model: