Sample CodemacOSReviewed 2026-07-21View on Apple Developer

Building a passthrough file system

At a glance

Item Summary
Purpose Expose an existing path as its own file system by using the FSKit framework.
App architecture A Swift sample bundle with entry-bearing project variants Passthrough, PassthroughAppEx, each leading to FSKit APIs.
Main patterns No named application pattern supported by the extracted structure
Project style 7 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries.

Project structure

Source bundle/
├── Passthrough/
│   ├── PassthroughApp.swift
│   ├── ContentView.swift
│   └── Passthrough.entitlements
├── PassthroughAppEx/
│   ├── PassthroughAppEx.swift
│   ├── PassthroughFileSystem.swift
│   ├── PassthroughFSItem.swift
│   ├── PassthroughFSVolume+FSVolumeOperations.swift
│   ├── PassthroughFSVolume.swift
│   └── Info.plist
├── Configuration/
│   └── SampleCode.xcconfig
└── Passthrough.xcodeproj/
    ├── .xcodesamplecode.plist
    └── project.pbxproj

Structure observations

  • Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
  • Primary languages: Swift.
  • The verified tree contains 6 project/configuration file(s) and 8 source declaration(s).

Overall architecture

Reference code

Passthrough/PassthroughApp.swift:10 — architecture anchor

@main
struct PassthroughApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

Interpretation

The branches represent separate entry-bearing project variants in the downloaded bundle, not runtime calls between those variants. Each branch is intentionally collapsed at the documented framework boundary; the detailed target-local flow remains in the cited files. Ownership is claimed only where the next section cites a stored property or assignment.

Ownership and state

Ownership evidence

PassthroughAppEx/PassthroughFileSystem.swift:12 — stored dependency or nearest verified ownership anchor

    static let passthroughfs = Logger(subsystem: "com.apple.fskit.PassthroughFS", category: "default")
Owner Object or state Relationship Mutation authority
PassthroughFileSystem Logger (passthroughfs) creates and retains Initialized by the owner; the binding is immutable
PassthroughFileSystem FSPathURLResource (resource) stores or receives App/module collaborators
PassthroughFileSystem Containerstatus (containerStatus) stores or receives App/module collaborators
PassthroughFSItem Int32 (fileDescriptor) owns value state App/module collaborators

Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.

Class and protocol design

Passthrough/PassthroughApp.swift:11 — representative type boundary

struct PassthroughApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
Type Responsibility Depends on or conforms to
PassthroughApp Application entry and top-level composition App
ContentView User-interface presentation and input forwarding View
PassthroughFileSystem Runs entity-component-system update logic FSUnaryFileSystem & FSUnaryFileSystemOperations
PassthroughAppEx Represents a feature value or composable behavior UnaryFileSystemExtension
PassthroughFSItemOpenMode Defines a closed set of feature states or choices Int32
PassthroughFSItem Represents feature data FSItem
CommonAttributes Represents a feature value or composable behavior Concrete collaborators/imported frameworks
PassthroughFSVolume Owns feature behavior and collaborator lifecycle FSVolume

No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.

Access control

Symbol Access Verified effect Likely rationale
initInode (PassthroughAppEx/PassthroughFSItem.swift:79) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: hide an implementation step that is not part of the collaboration surface.
openWithMode (PassthroughAppEx/PassthroughFSItem.swift:90) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: hide an implementation step that is not part of the collaboration surface.
volumeStatistics (PassthroughAppEx/PassthroughFSVolume+FSVolumeOperations.swift:33) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.
activate (PassthroughAppEx/PassthroughFSVolume+FSVolumeOperations.swift:57) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.

Reference code

PassthroughAppEx/PassthroughFSItem.swift:79 — representative boundary

    private func initInode() throws {
        var statResult = stat()
        _ = try throwErrno { fstat(self.fileDescriptor, &statResult) }
        self.inode = statResult.st_ino
    }

Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.

Logic ownership and placement

Logic Owning type or file Placement rationale
Application entry and top-level composition PassthroughApp The source’s App suffix makes this role explicit.
Runs entity-component-system update logic PassthroughFileSystem The source’s System suffix makes this role explicit.
User-interface presentation and input forwarding ContentView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
No named application pattern Passthrough/PassthroughApp.swift:10 The verified source directly composes concrete framework types; this document avoids forcing a pattern name.

Naming conventions

  • Types: App: PassthroughApp; System: PassthroughFileSystem; View: ContentView.
  • Protocols: no local protocol declaration in the scanned source.
  • Methods: throwErrno, createVolumeNameFromPath, loadResource, unloadResource, probeResource, initInode, openWithMode, upgradeOpenMode.
  • Files: Passthrough/PassthroughApp.swift, PassthroughAppEx/PassthroughAppEx.swift, Passthrough/ContentView.swift, PassthroughAppEx/PassthroughFileSystem.swift, PassthroughAppEx/PassthroughFSItem.swift, PassthroughAppEx/PassthroughFSVolume.swift.

Architecture takeaways

  • PassthroughApp is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches FSKit, ExtensionFoundation, SwiftUI through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
  • Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
  • Access-control conclusions separate verified language visibility from the likely design rationale.
  • The source does not justify labeling the design protocol-oriented.

Source map

Source file Relevant symbols
Passthrough/PassthroughApp.swift PassthroughApp
PassthroughAppEx/PassthroughAppEx.swift PassthroughAppEx
Passthrough/ContentView.swift ContentView
PassthroughAppEx/PassthroughFileSystem.swift PassthroughFileSystem
PassthroughAppEx/PassthroughFSItem.swift PassthroughFSItemOpenMode, PassthroughFSItem
PassthroughAppEx/PassthroughFSVolume+FSVolumeOperations.swift CommonAttributes
PassthroughAppEx/PassthroughFSVolume.swift PassthroughFSVolume