---
title: No Xiph libs
description: 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).

## Configuration Methods

### VS Code Configuration (all platforms)
Add to `.vscode/launch.json`:
```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"
```
<Card title="Screenshot">
![AS setup1](https://github.com/alnitak/flutter_soloud_docs/raw/main/img/AS_edit_conf1.png)
![AS setup2](https://github.com/alnitak/flutter_soloud_docs/raw/main/img/AS_edit_conf2.png)
</Card>

### 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 except web)
```bash
# 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:
```bash
# 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 |

<Info>
**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.
</Info>

#### 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`:
```ruby
ENV['NO_XIPH_LIBS'] = '1'
```

Then reinstall pods:
```bash
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):
```bash
export NO_XIPH_LIBS="1" && flutter run
```

#### Swift Package Manager (SPM)

SPM only supports the **environment variable** method:

```bash
# Run without Ogg/Opus/Vorbis/FLAC
export NO_XIPH_LIBS="1" && flutter run
```

Or create a build script for convenience:
```bash
#!/bin/bash
# build_no_xiph.sh
export NO_XIPH_LIBS=1
flutter build macos --release
```

<Warning>
**Important**: When switching between CocoaPods and SPM, or when changing the `NO_XIPH_LIBS` setting:

1. For CocoaPods: Clean and reinstall pods
   ```bash
   cd ios  # and/or cd macos
   rm -rf Pods Podfile.lock
   pod install --repo-update
   ```

2. For SPM: Clean build cache
   ```bash
   flutter clean
   ```

3. Check which build system Flutter is using:
   ```bash
   flutter config --enable-swift-package-manager  # Use SPM
   flutter config --no-enable-swift-package-manager  # Use CocoaPods
   ```
</Warning>

### Web Platform

1. Edit `web/compile_wasm.sh`
2. Change `NO_XIPH_LIBS="0"` to `NO_XIPH_LIBS="1"`
3. Rebuild WASM files (ie run `web/compile_wasm.sh`)

Requirements:
- Emscripten installed
- Linux or MacOS for compilation
- Windows users need WSL

<Warning>IDE environment variables are ignored for web builds.</Warning>

## Impact on Functionality

When built without Opus/Vorbis:
- `setBufferStream()` and `readSamplesFrom*()` using Opus/Vorbis/FLAC formats will throw exceptions
- Other audio formats remain fully functional
- Binary size reduces by 600~1500 KB
- All other features work normally
