TextReader is a SwiftUI-based iOS application built for a focused text reading and narration experience. It lets you import, organize, read, and listen to plain-text content, with deep customization, background audio playback, and AI-assisted prompt workflows.
Custom Prompt for AI demo: https://github.com/user-attachments/assets/5b297d9c-38e1-41f1-996b-b519b604e81a
- Paginated Reading — Text is automatically split into easily navigable pages.
- Text-to-Speech (TTS) — Audio narration powered by
AVSpeechSynthesizer, with play / pause control. - Customizable Narration
- Voice Selection — Choose from available system voices (optimized for Chinese voices).
- Speed Control — Adjust narration speed (1.0x, 1.5x, 1.75x, 2.0x, 3.0x).
- Sleep Timer — Long-press the Play button to reveal a radial timer picker and auto-stop narration after a set number of minutes.
- Background Playback — Keep listening while the app is backgrounded or the device is locked (
audiobackground mode). - Remote Controls — Play / pause and next / previous page via headphones or Control Center (
MPRemoteCommandCenter). - Now Playing Integration — Shows the current book title, page, and controls on the lock screen and in Control Center.
- Dark Mode — Switch between light and dark themes, with the choice persisted.
- Multiple Import Methods
- File Import — Import
.txtfiles via the system document picker (local storage or iCloud Drive). Supports UTF-8 and GBK / GB18030 encodings. - Paste Text — Create a book by pasting text. Title can be set manually or auto-generated from the first 10 characters.
- Share Sheet Import — Receive text shared from other apps (Notes, Safari, etc.) through the iOS Share Extension, handling
public.plain-textandpublic.text. Shared items are exchanged via an App Group inbox. - Wi-Fi Transfer — Push
.txtfiles from a computer on the same network through an in-app web interface.
- File Import — Import
- Book Library
- Lists all imported and built-in books.
- Sorts by last-accessed time, surfacing the most recently opened book first.
- Shows last-accessed time in friendly form (e.g. "Read just now", "Read 5 minutes ago").
- Progress Persistence — Automatically saves current page and total pages per book.
- Built-in Book — Ships with a "User Guide" (使用说明.txt) as a default book.
- Full-Text Search — Search within the currently open book.
- Live Search — Results update as you type.
- Keyword Highlighting — Matched keywords are highlighted (yellow background, bold).
- Contextual Preview — Each result shows a snippet with surrounding context.
- No Results State — Displays a clear "No relevant content found" message.
- Page Summaries — When the search bar is empty, shows up to 100 equally spaced page snippets for quick navigation.
- Interactive Page Slider
- Tap or drag the progress bar to reveal a slider for quick page jumps.
- The slider auto-hides after 1.5 seconds of inactivity.
- Long-press the progress bar for continuous dragging.
- Haptic Feedback — Subtle vibrations on page changes and other interactions.
- "Big Bang" Word Segmentation
- Long-press the reading view to trigger word segmentation via
NLTokenizer. BigBangViewrenders tokens as selectable blocks.- Drag to select continuous tokens for copying.
- Long-press the reading view to trigger word segmentation via
- Prompt Templates
- After selecting text in Big Bang view, apply a preset or custom template.
- Placeholders
{selection},{page}, and{book}are substituted automatically. - The generated prompt is copied to the clipboard and can optionally open a Perplexity AI search.
- Built-in defaults include "总结式" (summarize) and "翻译-EN" (translate to English); templates can be added, edited, and deleted.
- Tuned paragraph / letter spacing and a larger base font for readability.
- Linear progress bar for visual page tracking.
- Prominent circular Play / Pause button.
- Segmented speed selector for quick adjustments.
- Removed the startup title flicker for a smoother launch.
- iOS 26.0 or later
- Xcode 26.0 or later (for development)
- macOS 15.0 or later (for development with Xcode)
- Clone the repository:
git clone https://github.com/your-repository-url/TextReader.git cd TextReader - Open the project — Open
TextReader.xcodeprojin Xcode. - Select a target — Choose an iOS device or simulator.
- Build & run.
You can also build, install, and launch directly from the command line:
make installIf multiple devices are connected, specify one explicitly:
make install DEVICE_NAME="KAI"Other useful commands:
make devices # list connected devices
make install-simulator # build and run on a simulator- Book List — Tap the book icon in the navigation bar; select a book to start reading.
- Importing — Tap "+" in the book list to import via Files, Paste Text, or Wi-Fi Transfer.
- Reading — Tap the upper area for the previous page or the lower area for the next; use the progress slider to jump.
- Narration — Tap Play / Pause to control narration; long-press Play to set a sleep timer; adjust voice and speed in the control panel.
- Search — Tap the magnifying-glass icon to search within the current book.
- Big Bang & Prompts — Long-press text in the reader to segment words, select tokens, then use the Templates menu.
- Dark Mode — Toggle from the control panel.
- SwiftUI — Entire UI and app structure.
- AVFoundation —
AVSpeechSynthesizerfor TTS,AVAudioSessionfor audio session management. - MediaPlayer —
MPRemoteCommandCenterandMPNowPlayingInfoCenterfor background control and lock-screen integration. - NaturalLanguage —
NLTokenizerfor Big Bang word segmentation. - Network — Powers the Wi-Fi file transfer service.
- Combine — Manages asynchronous events and state.
- App Groups — Shared inbox for handing off content from the Share Extension to the main app.
- Core iOS Frameworks — File management and persistence (
UserDefaults, JSON for library metadata).
TextReader/
├── Shared/ # Code shared between app & extension (SharedImportStore)
├── TextReader/
│ └── TextReader/
│ ├── Application/ # App entry point (TextReaderApp)
│ ├── Managers/ # Library, Speech, Settings, AudioSession, Template
│ ├── Models/ # Book, BookProgress, PromptTemplate, AccentColor
│ ├── Services/ # SearchService, TextPaginator, Tokenizer, WiFiTransfer
│ ├── ViewModels/ # ContentViewModel (central orchestrator)
│ ├── Views/ # SwiftUI views (BookList, MainView, Search, BigBang, …)
│ ├── Resources/ # Built-in books (使用说明.txt)
│ └── Supporting Files/ # Utilities & entitlements
├── TextReaderExtension/ # Share Extension target
├── TextReaderTests/ # Unit tests
└── TextReaderUITests/ # UI tests
The app follows an MVVM design with clear separation of concerns:
- ViewModel —
ContentViewModelis the central orchestrator between views and business logic. - Managers —
LibraryManager,SpeechManager,SettingsManager,AudioSessionManager, andTemplateManager, each with a single, well-defined responsibility. - Services —
SearchService,TextPaginator, andWiFiTransferServiceencapsulate discrete capabilities. - Persistence —
LibraryManagerstores library metadata and reading progress as JSON;SettingsManagerpersists user preferences viaUserDefaults;TemplateManagersaves prompt templates totemplates.json. - Organized layout — Code is grouped into Models, ViewModels, Views, Services, and Managers for maintainability.
Unit and UI tests live in TextReaderTests/ and TextReaderUITests/, covering search composition state, the shared import flow, and core app behavior. Run them from Xcode (Product ▸ Test) or via xcodebuild test.
This project is licensed under the MIT License. See the LICENSE file for details.
Copyright (c) 2024 KAI
