Skip to content

Instantly share code, notes, and snippets.

@fathurrohman26
Created July 16, 2024 16:49
Show Gist options
  • Save fathurrohman26/e4358dcf023d92db8a962e445e28858e to your computer and use it in GitHub Desktop.
Save fathurrohman26/e4358dcf023d92db8a962e445e28858e to your computer and use it in GitHub Desktop.
When working with Flutter macOS applications, you might encounter pod errors while installing dependencies. These errors are often related to environment variables not being set correctly, which can cause issues with CocoaPods. This guide provides a temporary solution to fix these pod errors by setting the appropriate environment variables.
# Temporary solution to fix pod errors while installing Flutter dependencies for a Flutter macOS app.
# Usage:
# 1. Open your terminal.
# 2. Before running `flutter pub get`, source the environment variables:
# $ source ~/.podfile # Adjust the path to the actual location of this script if needed.
# 3. Then run:
# $ flutter pub get
# Set environment variables to fix pod errors
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
@fathurrohman26
Copy link
Author

Here's a detailed description of the provided solution for fixing pod errors while installing Flutter dependencies for a macOS app:


Fixing Pod Errors for Flutter macOS Apps

When working with Flutter macOS applications, you might encounter pod errors while installing dependencies. These errors are often related to environment variables not being set correctly, which can cause issues with CocoaPods. This guide provides a temporary solution to fix these pod errors by setting the appropriate environment variables.

Steps to Fix Pod Errors

  1. Create an Environment Variables Script

    First, create a script file that sets the necessary environment variables. This script ensures that the language settings are correctly configured, which can help resolve pod errors.

    • Create a file named ~/.podfile (or another name of your choice) and add the following content:

      # Set environment variables to fix pod errors
      export LANG=en_US.UTF-8
      export LANGUAGE=en_US.UTF-8
      export LC_ALL=en_US.UTF-8
  2. Source the Script in Your Terminal

    Before running flutter pub get to install dependencies, you need to source the script to set the environment variables in your terminal session.

    • Open your terminal.

    • Source the script by running:

      source ~/.podfile  # Adjust the path if the script is saved elsewhere
  3. Run Flutter Pub Get

    After sourcing the script, you can proceed to install the Flutter dependencies without encountering pod errors.

    • Run the following command:

      flutter pub get

Usage Summary

  1. Create the environment variables script:

    • Save the provided environment variable settings into a file, typically ~/.podfile.
  2. Source the script:

    • In your terminal, run:
      source ~/.podfile
  3. Run flutter pub get:

    • After sourcing the script, install the Flutter dependencies with:
      flutter pub get

Explanation of Environment Variables

  • LANG=en_US.UTF-8: Sets the language to US English with UTF-8 encoding.
  • LANGUAGE=en_US.UTF-8: Specifies the language setting for the application.
  • LC_ALL=en_US.UTF-8: Overrides all locale settings with US English and UTF-8 encoding.

By setting these environment variables, you ensure that the language and locale settings are correctly configured, which helps prevent pod-related errors during dependency installation in Flutter macOS projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment