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 Scheme → Run → Environment Variables2. Add: REACHU_CONFIG_TYPE = dark-streaming
3. Run → SDK automatically uses dark streaming theme
Available Environment Variables
Theme Configuration
| Variable | Values | Description |
|---|---|---|
REACHU_CONFIG_TYPE | dark-streaming, automatic, example | Selects configuration file |
REACHU_API_KEY | your-api-key | Override API key |
REACHU_ENVIRONMENT | production, sandbox | Override 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
Method 1: Xcode Environment Variables (Recommended)
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 Settings → Info → Configurations2. 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:
- Environment Variable(
REACHU_CONFIG_TYPE) - Highest Priority2. Specific Config Files(in order):
reachu-config-dark-streaming.jsonreachu-config-automatic.jsonreachu-config-example.jsonreachu-config.json
- Fallbackto default SDK configuration
Visual Comparison
Dark Streaming vs Automatic
| Aspect | Dark Streaming | Automatic |
|---|---|---|
| Background | Pure Black (#000000) | System Adaptive |
| Cards | Almost Black (#0D0D0F) | Adaptive |
| Text | High Contrast White | System Adaptive |
| Primary | Vibrant Blue (#0066FF) | iOS Blue (#0A84FF) |
| Use Case | Streaming, Gaming, Media | General Apps |
Troubleshooting
Environment Variable Not Working
- Check spelling:
REACHU_CONFIG_TYPE(case sensitive) - Verify value: Must be
dark-streaming,automatic, orexample - Restart app: Environment variables load at app startup
- Check logs: Look for configuration loading messages in console
Configuration File Not Found
- Verify file exists: Check if JSON file is in your project
- Check target membership: File must be added to app target
- Validate JSON: Use JSON validator to check syntax
- 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 Scheme → Environment 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
- Use environment variables for development - Quick theme switching
- Use .xcconfig files for release builds - More reliable and structured
- Keep configuration files in version control - Team consistency
- Test all theme configurations - Ensure compatibility
- Document custom configurations - Help team members understand choices
- Use meaningful configuration names - Make intent clear
Next Steps
- Complete Configuration Guide
- Dark/Light Mode Guide
- UI Components Documentation
- Complete App Examples
Ready to customize your Reachu experience with instant theme switching!