Without Opus/Vorbis
Configure builds without OGG, Opus, Vorbis, and FLAC libraries to reduce binary size
Overview
The OGG, Opus, Vorbis, and FLAC libraries are embedded by default in flutter_soloud. However, if you don't need streaming capabilities, you can exclude these libraries to reduce your app's binary size by 600~3000 KB (depending on platform).
VS Code Configuration (all platforms)
Add to .vscode/launch.json:
{
"name": "Flutter debug", // and/or other build configurations
"type": "dart",
"request": "launch",
"program": "lib/main.dart",
"env": {
"NO_XIPH_LIBS": "1"
}
}
Android Studio Setup
Add under Run/Debug Configurations:
Environment Variables: NO_XIPH_LIBS="1"
Screenshot


Gradle Build
It is also possible to configure the environment variables in the android/gradle.properties:
NO_XIPH_LIBS=true # add this line
or int the android/build.gradle.kts add this snippet:
allprojects { extra["NO_XIPH_LIBS"] = "true" }
Command Line Build (should work on all platforms)
# Build without Opus/Ogg
flutter clean
flutter pub get
export NO_XIPH_LIBS="1" && flutter run
# Reset to default (with Opus/Ogg)
flutter clean
flutter pub get
unset NO_XIPH_LIBS && flutter run # Unsets the environment variable
Linux Setup
If NO_XIPH_LIBS is not set and therefore libraries are linked, by default the build will link the precompiled libraries for Ogg, Opus, Vorbis, and FLAC.
A new environment variable could be set to try linking the embedded libraries. Here a brief usage:
# Default - use bundled libraries (backward compatible)
flutter build linux
# Prefer system libraries, fallback to bundled
TRY_SYSTEM_LIBS_FIRST=1 flutter build linux
# Skip Opus/Ogg/Vorbis/FLAC entirely
NO_XIPH_LIBS=1 flutter build linux
iOS/MacOS Setup
Flutter supports two build systems for iOS and macOS: CocoaPods (legacy) and Swift Package Manager (SPM).
| Build System | Podfile Method | Environment Variable Method |
|---|---|---|
| CocoaPods | ✅ Supported | ✅ Supported |
| Swift Package Manager | ❌ Not supported | ✅ Supported |
Recommendation for CocoaPods users: Use the Podfile method (ENV['NO_XIPH_LIBS'] = '1') as it's persistent and doesn't require setting the variable for every build command.
CocoaPods (Default/Legacy)
CocoaPods supports both configuration methods. Choose the one that best fits your workflow:
Method A: Podfile (Persistent - Recommended)
Add to ios/Podfile or macos/Podfile:
ENV['NO_XIPH_LIBS'] = '1'
Then reinstall pods:
cd ios # and/or cd macos
rm -rf Pods Podfile.lock
pod install --repo-update
Method B: Environment Variable (Per-build)
Set the variable when building (no Podfile changes needed):
export NO_XIPH_LIBS="1" && flutter run
Swift Package Manager (SPM)
SPM only supports the environment variable method:
# Run without Ogg/Opus/Vorbis/FLAC
export NO_XIPH_LIBS="1" && flutter run
Or create a build script for convenience:
#!/bin/bash
# build_no_xiph.sh
export NO_XIPH_LIBS=1
flutter build macos --release
Important: When switching between CocoaPods and SPM, or when changing the NO_XIPH_LIBS setting:
-
For CocoaPods: Clean and reinstall pods
cd ios # and/or cd macos rm -rf Pods Podfile.lock pod install --repo-update -
For SPM: Clean build cache
flutter clean -
Check which build system Flutter is using:
flutter config --enable-swift-package-manager # Use SPM flutter config --no-enable-swift-package-manager # Use CocoaPods