Building from Source
Relevant source files
The following files were used as context for generating this wiki page:This guide provides technical instructions for developers to compile and run the VoiceInk application from its source code. Building from source is intended for those who wish to contribute to the project, inspect the codebase, or create custom builds. For regular use, it is recommended to download the official version from the website, which includes benefits like automatic updates and priority support.
The core of VoiceInk's transcription capability relies on the whisper.cpp library, which must be built as a separate framework before the main application can be compiled. This process ensures that the high-performance inference engine is correctly integrated. For guidelines on contributing code after a successful build, please refer to the Contributing Guidelines.
Sources: BUILDING.md, README.md:32-35, CONTRIBUTING.md
Prerequisites
Before starting the build process, ensure your development environment meets the following requirements.
| Requirement | Version/Details |
|---|---|
| Operating System | macOS 14.0 or later |
| IDE | Xcode (latest version recommended) |
| Language | Swift (latest version recommended) |
| Tools | Xcode Command Line Tools |
Sources: BUILDING.md:5-9, README.md:38-39, CONTRIBUTING.md:54-57
Build Process
The build is a two-stage process: first, you must compile the whisper.cpp dependency into an XCFramework, and second, you build the VoiceInk application itself, linking against the newly created framework.
This diagram illustrates the high-level build workflow.
Sources: BUILDING.md:11-28
1. Building the whisper.cpp Framework
The whisper.cpp library provides the core transcription engine. It must be compiled into a macOS-compatible XCFramework.
-
Clone the
whisper.cpprepository:git clone https://github.com/ggerganov/whisper.cpp.git cd whisper.cpp -
Execute the build script:
./build-xcframework.shThis script compiles the C++ code and packages it into a universal framework suitable for Apple platforms. The output will be located at
whisper.cpp/build-apple/whisper.xcframework.
Sources: BUILDING.md:12-18
2. Building the VoiceInk Application
Once the whisper.xcframework is ready, you can proceed to build the main application.
-
Clone the VoiceInk repository:
git clone https://github.com/Beingpax/VoiceInk.git cd VoiceInk -
Integrate the Framework: Open the
VoiceInk.xcodeprojfile in Xcode. Add thewhisper.xcframeworkyou built in the previous step to the project. This can be done by dragging the framework file into the Xcode project navigator or by adding it under the "Frameworks, Libraries, and Embedded Content" section in the target's General settings. -
Build and Run: Use Xcode to build and run the project.
- Build:
Cmd+BorProduct > Build - Run:
Cmd+RorProduct > Run
- Build:
Sources: BUILDING.md:20-28
Core Dependencies
VoiceInk relies on several open-source libraries to provide its features. When building from source, these dependencies are managed via Swift Package Manager and are automatically fetched by Xcode.
| Dependency | Purpose | Source |
|---|---|---|
| whisper.cpp | High-performance inference of OpenAI's Whisper model for local transcription. | README.md:55-56 |
| Sparkle | Enables automatic application updates (primarily for pre-compiled versions). | README.md:59-60 |
| KeyboardShortcuts | Provides user-customizable global keyboard shortcuts. | README.md:61-62 |
| LaunchAtLogin | Manages the "Launch at login" functionality. | READMEmd:63-64 |
| FluidAudio | Used for Parakeet model implementation. | README.md:57-58 |
| Zip | Handles file compression and decompression, used for CoreML models. | README.md:67-68 |
| SelectedTextKit | A library for getting the currently selected text on screen. | README.md:69-70 |
Development and Testing
For those looking to contribute, the development process involves more than just building the application.
- Configuration: Use the
Debugbuild configuration in Xcode for development. - Testing: Before submitting changes, run the project's test suite to ensure all tests pass. New features should be accompanied by new tests.
- Contribution Policy: Before starting significant work, it is required to open an issue to discuss the proposed changes with the project maintainers. This ensures alignment with the project's direction.
Sources: BUILDING.md:30-43, CONTRIBUTING.md:7-22, 60-65
Post-Build: Model Management
After building and running VoiceInk, the application needs transcription models to function. The WhisperState class, particularly in WhisperState+LocalModelManager.swift, handles the logic for downloading, storing, and loading these models.
- Model Storage: Models are stored in a dedicated directory within the application's support files. The
createModelsDirectoryIfNeeded()function ensures this directory exists. - Model Structure: The
WhisperModelstruct defines a model, including its name, local file URL, and optional Core ML-accelerated encoder URLs. - Model Loading: The
loadModel(_:)function loads a selected.binfile into theWhisperContext, making it ready for transcription.
The following diagram shows the sequence for downloading a new model, which includes fetching the main model and its corresponding Core ML components if available.
This flow shows how both the main GGML model (.bin) and the optional, optimized Core ML encoder model are downloaded and prepared for use.
Sources: VoiceInk/Whisper/WhisperState+LocalModelManager.swift
Building from Source vs. Official Release
Building the application from source provides a different experience compared to the official, pre-compiled version available from the project website.
| Feature | Built from Source | Official Release |
|---|---|---|
| Automatic Updates | ❌ Disabled. Updates must be pulled manually from the Git repository. | ✅ Enabled via the Sparkle framework. |
| Update Mechanism | Manual git pull and rebuild. | Automatic checks and downloads based on appcast.xml. |
| Support | Community support via GitHub Issues. | Priority support via Discord and email. |
| Code Access | Full access to inspect and modify. | Binary application only. |
The official release uses the Sparkle framework for updates. The UpdaterViewModel class initializes the SPUStandardUpdaterController, which periodically checks the appcast.xml file for new versions. When building from source, this mechanism is present in the code but will not function without a proper code-signing and release setup.
Sources: README.md:32-35, VoiceInk/VoiceInk.swift:165-191, appcast.xml
Troubleshooting
If you encounter issues during the build process, follow these steps:
- Clean Build Folder: In Xcode, use
Cmd+Shift+Kto clean the build folder. - Verify Versions: Ensure your macOS and Xcode versions meet the prerequisites.
- Check Dependencies: Confirm that
whisper.xcframeworkwas built successfully and is correctly linked in the Xcode project. A common error is a missing or improperly built framework. - Re-clone: If issues persist, try deleting the local repositories for both VoiceInk and
whisper.cppand starting the process over.
For further assistance, consult the project's GitHub issues.
Sources: BUILDING.md:45-54