Learn More       Talk to an Expert
Using Environment Variables in iOS, and Android Projects

Using Environment Variables in iOS, and Android Projects

Managing environment variables is crucial for customizing build configurations and securely handling sensitive data like API keys and passwords. Appcircle provides a streamlined approach for defining, managing, and utilizing environment variables across iOS, and Android projects, ensuring flexible and secure build processes.

Creating Environment Variable Groups

Organize your environment variables into groups for better management and reuse across multiple projects or build profiles.

Adding Key and Text-Based Value Pairs

Add key-value pairs where the value is text. Sensitive values can be marked as secret to hide them during the build process.

Example: A development team adds key-value pairs for API_URL (https://api.example.com) and API_KEY (your_api_key_here, hidden) in the environment variable group.

Adding Files as Environment Variables

Include files as environment variables for use in build workflows, such as configuration files or certificates.

Example: A developer uploads a configuration file as an environment variable with the key CONFIG_FILE, which is then used during the build process.

Using Environment Variable Groups in Builds

Assign the created environment variable groups to your build profiles to make the variables available during the build.

Example: In the staging build configuration, the team assigns the "Staging" variable group, ensuring that staging-specific settings are applied during the build.

Using Environment Variables in iOS Projects

Integrate environment variables into iOS projects using Xcode configuration files (.xcconfig files). This allows you to manage project-wide variables without hardcoding sensitive information.

Example: A developer creates a .xcconfig file to store variables like API_URL and API_KEY. These variables are referenced in the project's Info.plist and accessed in the code. During the build process, Appcircle's custom scripts replace placeholders in the .xcconfig file with actual environment variable values, ensuring sensitive data is not exposed in the source code.

Using Environment Variables in Android Projects

Access environment variables in Android projects through Gradle build configurations. This method lets you define variables that can be used throughout your application.

Example: A developer modifies the build.gradle file to include environment variables for API_URL and API_KEY. These variables are then accessible in the application via the BuildConfig class. By assigning different variable groups in Appcircle, the developer can easily switch between development, staging, and production environments without changing the code.

Best Practices and Considerations

Security: Mark sensitive variables as secret in Appcircle to prevent exposure.

Environment-Specific Configurations: Create separate variable groups for different environments like development, staging, and production.

Consistent Naming Conventions: Use clear and consistent names for your variables and groups.

Avoid Hardcoding: Do not embed sensitive information in your source code; use environment variables instead.

REQUEST FOR MORE SPECIFICS

Get Started with Appcircle

Save time, reduce costs, and increase developer productivity now.

Join Our Newsletter

Get informed about news, new releases, and mobile DevOps.