How to set something like "dart-define" also in fastlanen

244 Views Asked by At

I have implemented CI/CD for my flutter app in a way that i have a fastlane for ios and android and i am calling my fastlane from the github actions and my flutter app depends on some Env variables during build time, so in development i just use flutter run with -dart-define parameter and later in my flutter app i get the value through String.fromEnvironment('FLUTTER_BUILD_TYPE') all is fine but when i compile and push my app to firebase app distribution with fastlane i am not able to set the FLUTTER_BUILD_TYPE environment variable in fastlane.

i have tried multiple ways but without success

for example:
setting the xcargs in gym like this

gym(
    clean: true,
    verbose: true,
    scheme: "Runner",
    export_method: "ad-hoc",
    xcargs: "FLUTTER_BUILD_TYPE='dev'",
    archive_path: "../build/ios/archive/Runner.xcarchive",
    output_directory: "./build/Runner",
    output_name: "my-app.ipa"
)

My github Workflow

on:
 push:
  branches: ["release_ready"]
 pull_request:
  branches: ["release_ready"]

 workflow_dispatch:

jobs:
 build:
  runs-on: macos-latest
   env:
    apiKey: ${{secrets.API_KEY}}


   steps:
    - uses: actions/checkout@v3
    - uses: maxim-lobanov/setup-xcode@v1
      with:
       xcode-version: latest-stable

    - name: Install Ruby
      uses: ruby/setup-ruby@v1
      with:
       ruby-version: "3.2.2"
       bundler-cache: true

    - name: Install Bundler and Gems
      working-directory: ios
      run: gem install bundler

    - uses: actions/setup-java@v3
      with:
       distribution: "zulu"
       java-version: "12.x"
       cache: "gradle"

    - name: "Install flutter"
      uses: subosito/flutter-action@v2
      with:
       flutter-version: "3.10.5"
       channel: "stable"
       cache: true
    - run: flutter doctor -v

    - name: Get dependencies
      run: flutter pub get

    - name: Install Gems and cocoapods
      working-directory: ios
      run: |
       bundle install
       gem install cocoapods
       pod install

    - name: Generate files and keys
       run: flutter pub run build_runner build --delete-conflicting outputs

    - name: Run Fastlane
      working-directory: ios
      run: bundle exec fastlane ios_upload_to_firebase_app_distribution
      env:
        FLUTTER_BUILD_TYPE: dev # i want this to be passed in my flutter app
        FIREBASE_IOS_APP_ID: ${{secrets.FIREBASE_IOS_APP_ID}}
        FIREBASE_CLI_TOKEN_IOS: ${{secrets.FIREBASE_CLI_TOKEN_IOS}}
        GIT_BASIC_AUTHORIZATION: ${{secrets.GIT_BASIC_AUTHORIZATION}}
        MATCH_KEYCHAIN_PASSWORD: ${{secrets.MATCH_KEYCHAIN_PASSWORD}}
        MATCH_PASSWORD: ${{secrets.MATCH_PASSWORD}}
        MATCH_KEYCHAIN_NAME: ${{secrets.MATCH_KEYCHAIN_NAME}}

i am just stuck in this problem and cant get out. My app will not show anything, when i am not set the FLUTTER_BUILD_TYPE during build

i will appreciate alot if someone can help me by this. Thank you

0

There are 0 best solutions below