Skip to content

Allow users to pass in Xcode build settings as env variables to "flutter build ios-framework" FLUTTER_XCODE_ #49378

Open

Description

@jmagman

This was done for all other commands via env variables with the FLUTTER_XCODE_ prefix (like FLUTTER_XCODE_CODE_SIGN_STYLE) with #43553 but was missed when creating build ios-framework command.

Example that should work, but doesn't:

$ FLUTTER_XCODE_IPHONEOS_DEPLOYMENT_TARGET="9.0" flutter build ios-framework --output=.`

Activity

  1. added
    platform-iosiOS applications specifically
    toolAffects the "flutter" command-line tool. See also t: labels.
    a: existing-appsIntegration with existing apps via the add-to-app flow
    on Jan 23, 2020
  2. self-assigned this
    on Jan 23, 2020
  3. jmagman commented on Jan 29, 2020

    @jmagman
    MemberAuthor

    It does already pass the environment variables to invocations of xcodebuild EXCEPT when building plugins.

  4. AntonKukoba1 commented on Feb 17, 2020

    @AntonKukoba1

    it kinda works. But you can't pass the arguments which start with minus. I.e. you can pass -derivedDataPath via FLUTTER_XCODE. Because FLUTTER_XCODE_-derivedDataPath variable cannot be created.

  5. jmagman commented on Feb 18, 2020

    @jmagman
    MemberAuthor

    it kinda works. But you can't pass the arguments which start with minus. I.e. you can pass -derivedDataPath via FLUTTER_XCODE. Because FLUTTER_XCODE_-derivedDataPath variable cannot be created.

    You can probably play with build settings like SYMROOT and MODULE_CACHE_DIR to get the behavior you want.
    https://help.apple.com/xcode/mac/11.4/#/itcaec37c2a6

  6. AntonKukoba1 commented on Mar 2, 2020

    @AntonKukoba1

    it kinda works. But you can't pass the arguments which start with minus. I.e. you can pass -derivedDataPath via FLUTTER_XCODE. Because FLUTTER_XCODE_-derivedDataPath variable cannot be created.

    You can probably play with build settings like SYMROOT and MODULE_CACHE_DIR to get the behavior you want.
    https://help.apple.com/xcode/mac/11.4/#/itcaec37c2a6

    Wouldn't it be simplier to have one environment variable (for example FLUTTER_XCODE) which will contain the string, which is just concatenated to the command line? So that any sophisticated combination of compilation flags could be added.

  7. bhavyalatha26 commented on Jul 12, 2020

    @bhavyalatha26

    Hi @jmagman,

    Is FLUTTER_XCODE prefix support available on stable channel ?

  8. jmagman commented on Jul 13, 2020

    @jmagman
    MemberAuthor

    @bhavyalatha26 FLUTTER_XCODE_* (like FLUTTER_XCODE_ARCHS) #43553 for flutter build ios and flutter run is in v1.10.15, so yes, stable. This issue is tracking that that mechanism doesn't work for flutter build ios-framework on any channel.

    FLUTTER_XCODE=<arbitrary injection of variables> as @AntonKukoba1 suggested isn't implemented anywhere.

  9. bhavyalatha26 commented on Jul 14, 2020

    @bhavyalatha26

    Thanks for the info @jmagman.

    I just need one more info as of how to pass these variables.

    For instance I added google maps package to my app and I am trying to pass the google maps key as XCODE env var to the AppDelegat.swift class as below

    import UIKit
    import Flutter
    import Firebase
    import GoogleMaps
    import Foundation
    
    @UIApplicationMain
    @objc class AppDelegate: FlutterAppDelegate {
      override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
      ) -> Bool {
        FirebaseApp.configure()
        let mapsKey = ProcessInfo.processInfo.environment["FLUTTER_XCODE_GOOGLE_MAPS_IOS_KEY"] ?? "no_key"
        GMSServices.provideAPIKey(mapsKey)
        GeneratedPluginRegistrant.register(with: self)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
      }
    }
    

    Flutter : stable 1.17.5
    XCode : 11.5

    I tried it in below 3 ways. But none of them worked.

    1.

    export FLUTTER_XCODE_GOOGLE_MAPS_IOS_KEY=<my-key>
    flutter run
    

    2.

    FLUTTER_XCODE_GOOGLE_MAPS_IOS_KEY=<my-key> flutter run
    

    3.

    flutter run --dart-define=FLUTTER_XCODE_GOOGLE_MAPS_IOS_KEY=<my-key>
    

    Can you help me the right way of doing this

  10. jmagman commented on Jul 14, 2020

    @jmagman
    MemberAuthor

    @bhavyalatha26 FLUTTER_XCODE_ isn't for setting environment variables, it's a build setting that gets passed to xcodebuild. Can you file a new issue requesting improved documentation, or ask on SO? This GitHub issue is tracking a specific bug related to the flutter build ios-framework command

  11. bhavyalatha26 commented on Jul 15, 2020

    @bhavyalatha26

    Ok thank you @jmagman

  12. added
    P3Issues that are less important to the Flutter project
    on Aug 11, 2020
  13. removed their assignment
    on Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: existing-appsIntegration with existing apps via the add-to-app flowplatform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions