Getting Started & Setup
Relevant source files
The following files were used as context for generating this wiki page:
Writer is a distraction-free Markdown editor for macOS built with SwiftUI. It emphasizes a clean editing experience with live previews and robust export capabilities. The application leverages Swift's Observation framework for modern state management and Apple's Markdown framework for document parsing.
The setup process primarily involves configuring the local development environment in Xcode and initializing the application's workspace by selecting a root directory for document storage.
Sources: CLAUDE.md:1-12, Writer/WriterApp.swift:10-15
Development Environment Setup
To begin working on the Writer project, developers must use Xcode on macOS. The project structure is standard for SwiftUI applications.
Build and Run Instructions
The following commands and shortcuts are used to manage the project lifecycle:
- Open Project:
open Writer.xcodeproj - Build: Command + B (⌘B)
- Run: Command + R (⌘R)
Sources: CLAUDE.md:14-18
Key State Managers
The application initializes three primary state objects at launch within the WriterApp struct to manage the editor, appearance, and layout.
| Component | Responsibility |
|---|---|
EditorStore | Manages file tree, document persistence, and file operations. |
ThemeStore | Manages preview themes and typography settings. |
LayoutStore | Controls UI state such as the visibility of the preview pane. |
Sources: Writer/WriterApp.swift:13-17, CLAUDE.md:24-35
Application Architecture
Writer follows a centralized state management pattern using the @Observable macro. This allows views to reactively update when the underlying data changes without manual notification boilerplate.
State Flow Diagram
The following diagram illustrates how the EditorStore acts as the central hub for data flow between the file system and the user interface.
The app entry point injects these stores into the environment, making them accessible to ContentView and its subviews.
Sources: Writer/WriterApp.swift:75-79, CLAUDE.md:21-22, Writer/EditorStore.swift:14-30
Initial Workspace Configuration
Upon the first launch, Writer requires the user to select a "Writing Folder." This directory serves as the root for all file navigation and editing.
Security-Scoped Access
Because Writer is a macOS app that interacts with the file system, it uses security-scoped bookmarks to maintain access to the selected folder across application restarts.
The application uses URL.bookmarkData(options: .withSecurityScope) to persist these permissions.
Sources: Writer/EditorStore.swift:150-180, CLAUDE.md:46-49
Editor Configuration
The core editing experience is powered by a custom NSTextView wrapper that handles Markdown syntax highlighting and specific editor behaviors.
Editor Defaults
The MarkdownTextView is configured with specific settings to ensure a distraction-free environment:
- Font: System monospaced font (default size 16).
- Substitutions: Automatic quotes, dashes, and text replacements are disabled to prevent interference with Markdown syntax.
- Padding: Insets of 24pt (horizontal) and 12pt (vertical).
Sources: Writer/MarkdownTextView.swift:11-35
Supported File Types
Writer filters the file tree to only show editable text formats.
| File Extension | Description |
|---|---|
.md, .markdown | Standard Markdown documents. |
.txt, .text | Plain text documents. |
Sources: Writer/EditorStore.swift:302-310, CLAUDE.md:53-55
Keyboard Shortcuts for Setup & Navigation
Writer includes several built-in shortcuts to streamline the initial setup of files and folders within the workspace.
| Action | Shortcut | Source File |
|---|---|---|
| New File | ⌘N | WriterApp.swift:96 |
| New Folder | ⌘⇧N | WriterApp.swift:101 |
| Export to HTML | ⌘⇧E | WriterApp.swift:107 |
| Export to PDF | ⌘⇧P | WriterApp.swift:112 |
| Show/Hide Preview | ⌘⌥P | WriterApp.swift:126 |
| Format Tables | ⌘⇧F | WriterApp.swift:122 |
Summary
Setting up Writer involves opening the project in Xcode, building for macOS, and selecting a local folder to serve as the document library. The application's architecture ensures that once a folder is selected, access is persisted securely, and the Markdown editor is configured for technical writing with specific monospaced typography and disabled system text interventions.