Skip to main content

Environment Variables Guide

Quick theme switching and configuration management using environment variables in your iOS app.

Quick Start

Set environment variables in your app for instant theme switching without changing code:

**In Xcode:**1. Edit SchemeRunEnvironment Variables2. Add: REACHU_CONFIG_TYPE = dark-streaming 3. Run → SDK automatically uses dark streaming theme

Available Environment Variables

Theme Configuration

VariableValuesDescription
REACHU_CONFIG_TYPEdark-streaming, automatic, exampleSelects configuration file
REACHU_API_KEYyour-api-keyOverride API key
REACHU_ENVIRONMENTproduction, sandboxOverride environment

Theme Options

Dark Streaming Theme

REACHU_CONFIG_TYPE=dark-streaming

  • Background: Pure black (#000000)
  • Surface: Almost black (#0D0D0F)
  • Primary: Vibrant blue (#0066FF)
  • Ideal for: Streaming apps, gaming, media platforms

Automatic Theme

REACHU_CONFIG_TYPE=automatic

  • Background: Follows iOS system theme
  • Surface: Adaptive (#1C1C1E dark / #FFFFFF light)
  • Primary: iOS standard blue (#0A84FF)
  • Ideal for: General apps, ecommerce, productivity

Example Theme

REACHU_CONFIG_TYPE=example

  • Same as: Dark streaming theme
  • Purpose: Default template configuration

Setup Methods

Step 1: Configure in Xcode1. In your app project, click on the scheme name next to the run button 2. Select **"Edit Scheme..."**3. Go to "Run" → **"Environment Variables"**4. Click **"+"**to add a new variable 5. Add REACHU_CONFIG_TYPE with value dark-streaming or automatic

Step 2: Run Your App

 [Config] Using environment config type: dark-streaming
[Config] Loading configuration from: reachu-config-dark-streaming.json
[Config] Configuration loaded successfully: Dark Streaming Theme

Method 2: .xcconfig Files (Advanced)

Step 1: Create Configuration FilesCopy these files from the SDK demo app to your project:

DarkStreaming.xcconfig:

REACHU_CONFIG_TYPE = dark-streaming
REACHU_ENVIRONMENT = production

AutomaticTheme.xcconfig:

REACHU_CONFIG_TYPE = automatic
REACHU_ENVIRONMENT = production

Step 2: Setup Build Configurations1. Project SettingsInfoConfigurations2. DuplicateDebug configuration → "Debug-Dark" 3. AssignDarkStreaming.xcconfig to "Debug-Dark" 4. DuplicateDebug configuration → "Debug-Auto" 5. AssignAutomaticTheme.xcconfig to "Debug-Auto"

Step 3: Switch Configurations - Change scheme configuration to switch themes instantly

  • No code changes required

Method 3: Code Configuration

Override programmatically:

import ReachuCore

// Force specific configuration
try ConfigurationLoader.loadFromJSON(fileName: "reachu-config-dark-streaming")

// Or load based on condition
let isDarkModeApp = true
let configName = isDarkModeApp ? "reachu-config-dark-streaming" : "reachu-config-automatic"
try ConfigurationLoader.loadFromJSON(fileName: configName)

Required Configuration Files

Copy these files from the SDK demo app to your project:

YourApp/
reachu-config-dark-streaming.json # Dark theme config
reachu-config-automatic.json # Automatic theme config
reachu-config-example.json # Default config
reachu-config.json # Your custom config (optional)

**Important:**Files must be added to your app's target bundle in Xcode.

Configuration Priority

The SDK loads configuration in this order:

  1. Environment Variable(REACHU_CONFIG_TYPE) - Highest Priority2. Specific Config Files(in order):
  • reachu-config-dark-streaming.json
  • reachu-config-automatic.json
  • reachu-config-example.json
  • reachu-config.json
  1. Fallbackto default SDK configuration

Visual Comparison

Dark Streaming vs Automatic

AspectDark StreamingAutomatic
BackgroundPure Black (#000000)System Adaptive
CardsAlmost Black (#0D0D0F)Adaptive
TextHigh Contrast WhiteSystem Adaptive
PrimaryVibrant Blue (#0066FF)iOS Blue (#0A84FF)
Use CaseStreaming, Gaming, MediaGeneral Apps

Troubleshooting

Environment Variable Not Working

  1. Check spelling: REACHU_CONFIG_TYPE (case sensitive)
  2. Verify value: Must be dark-streaming, automatic, or example
  3. Restart app: Environment variables load at app startup
  4. Check logs: Look for configuration loading messages in console

Configuration File Not Found

  1. Verify file exists: Check if JSON file is in your project
  2. Check target membership: File must be added to app target
  3. Validate JSON: Use JSON validator to check syntax
  4. Check bundle: Files must be in app bundle, not just project

Common Console Messages

# Success
[Config] Configuration loaded successfully: Dark Streaming Theme

# Environment variable detected
[Config] Using environment config type: dark-streaming

# File found
[Config] Found config file: reachu-config-dark-streaming.json

# Error - file not found
Failed to load Reachu SDK configuration: fileNotFound

Development Workflow

For Testing Different Themes

**Quick Switch Method:**1. Edit SchemeEnvironment Variables2. ChangeREACHU_CONFIG_TYPE value 3. Runapp to see changes instantly

No need to: - Modify code

  • Change configuration files
  • Rebuild project
  • Copy/paste configurations

For Team Development

Setup Multiple Configurations:

# Developer 1 - Dark theme
REACHU_CONFIG_TYPE=dark-streaming

# Developer 2 - Auto theme
REACHU_CONFIG_TYPE=automatic

# QA Testing - Example theme
REACHU_CONFIG_TYPE=example

For CI/CD Pipelines

Environment-specific configurations:

# Development
export REACHU_CONFIG_TYPE=example
export REACHU_ENVIRONMENT=sandbox

# Staging
export REACHU_CONFIG_TYPE=automatic
export REACHU_ENVIRONMENT=sandbox

# Production
export REACHU_CONFIG_TYPE=dark-streaming
export REACHU_ENVIRONMENT=production

Best Practices

  1. Use environment variables for development - Quick theme switching
  2. Use .xcconfig files for release builds - More reliable and structured
  3. Keep configuration files in version control - Team consistency
  4. Test all theme configurations - Ensure compatibility
  5. Document custom configurations - Help team members understand choices
  6. Use meaningful configuration names - Make intent clear

Next Steps

Ready to customize your Reachu experience with instant theme switching!