Phone App Compilation
Relevant source files
The following files were used as context for generating this wiki page:
The phone_app is a Flutter companion application within the BT Speaker monorepo, designed for iOS and Android, but also supporting desktop platforms like Linux and Windows for development and testing. It functions as a WebSocket client that communicates with the Raspberry Pi (server) to control EQ settings, LED commands, and track metadata.
Sources: CLAUDE.md:12-17, README.md:21-25
Build System Architecture
The compilation process leverages Flutter's multi-platform capabilities, utilizing platform-specific build tools (CMake for desktop and standard Flutter tools for mobile). The project follows a workspace-based resolution as part of a Melos monorepo.
Dependency Management
The application depends on a shared core package and several external plugins for networking, storage, and URL handling.
| Dependency | Purpose |
|---|---|
bt_speaker_core | Shared models (BeatData, NowPlaying, EqSettings, LedCommand) |
flutter_bloc | State management using BLoC pattern |
app_links | Deep linking support |
flutter_secure_storage | Encrypted local storage |
http | HTTP client for standard requests |
url_launcher | Opening external browser links |
Sources: apps/phone_app/pubspec.yaml:34-45, CLAUDE.md:16-17
Desktop Compilation Flow (Linux/Windows)
For desktop targets, the project uses a two-tier CMake structure. The top-level CMakeLists.txt defines the project and binary names, while the flutter/ subdirectory manages the Flutter engine and plugin registration.
The diagram shows the sequence from the initial build command to the generation of a relocatable application bundle.
Sources: apps/phone_app/linux/CMakeLists.txt:46-55, apps/phone_app/windows/flutter/CMakeLists.txt:88-100
Linux Compilation Details
On Linux, the build requires system-level dependencies including GTK 3.0, GLib 2.0, and GIO 2.0. The build process generates a binary named bt_speaker with a unique application ID com.example.bt_speaker.
Key Build Targets
- flutter_assemble: Forces the Flutter tool to run every time to ensure assets and AOT libraries are current.
- bt_speaker: The main executable target linked against the Flutter library and GTK.
# Sources: apps/phone_app/linux/flutter/CMakeLists.txt:77-88
add_custom_command(
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/_phony_
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
VERBATIM
)
Windows Compilation Details
The Windows build utilizes cxx_std_17 and links against dwmapi.lib. The compilation process includes a C++ wrapper (cpp_client_wrapper) which provides the interface between the Windows runner and the Flutter engine.
Build Configurations
Supported modes include Debug, Profile, and Release. The runner uses a Win32 entry point defined in main.cpp.
The diagram represents the relationship between the native C++ runner, the Flutter wrapper library, and the external dependencies on Windows.
Sources: apps/phone_app/windows/CMakeLists.txt:39-47, apps/phone_app/windows/flutter/CMakeLists.txt:62-84
Compilation Environment Requirements
| Property | Value/Requirement |
|---|---|
| SDK Version | ^3.11.5 |
| Build Tool | Melos (for monorepo management) |
| C++ Standard (Linux) | C++14 |
| C++ Standard (Windows) | C++17 |
| Build Mode | Release (Default for production) |
Sources: apps/phone_app/pubspec.yaml:27, apps/phone_app/linux/CMakeLists.txt:39, apps/phone_app/windows/CMakeLists.txt:39
Conclusion
The phone app compilation process is a standardized Flutter multi-platform workflow integrated into a monorepo. It ensures that the companion app is built with all necessary shared models from bt_speaker_core while maintaining platform-specific configurations for Linux, Windows, and mobile environments.