Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jmagman opened this issue Jan 23, 2020 · 9 comments
Labels
a: existing-apps Integration with existing apps via the add-to-app flow P3 Issues that are less important to the Flutter project platform-ios iOS applications specifically team-ios Owned by iOS platform team tool Affects the "flutter" command-line tool. See also t: labels. triaged-ios Triaged by iOS platform team

Comments

@jmagman
Copy link
Member

jmagman commented Jan 23, 2020

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=.`
@jmagman jmagman added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. a: existing-apps Integration with existing apps via the add-to-app flow labels Jan 23, 2020
@jmagman jmagman self-assigned this Jan 23, 2020
@jmagman jmagman added this to Awaiting triage in Add-to-app - iOS tool review via automation Jan 23, 2020
@jmagman jmagman added this to Awaiting triage in Tools - existing app integration review via automation Jan 23, 2020
@jmagman jmagman moved this from Awaiting triage to Engineer reviewed in Add-to-app - iOS tool review Jan 23, 2020
@jmagman jmagman moved this from Awaiting triage to Engineer reviewed in Tools - existing app integration review Jan 23, 2020
@jmagman jmagman added this to To do in Add-to-app 2020Q1 via automation Jan 23, 2020
@jmagman
Copy link
Member Author

jmagman commented Jan 29, 2020

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

@AntonKukoba1
Copy link

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.

@jmagman
Copy link
Member Author

jmagman commented Feb 18, 2020

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

@AntonKukoba1
Copy link

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.

@bhavyalatha26
Copy link

Hi @jmagman,

Is FLUTTER_XCODE prefix support available on stable channel ?

@jmagman
Copy link
Member Author

jmagman commented Jul 13, 2020

@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.

@bhavyalatha26
Copy link

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

@jmagman
Copy link
Member Author

jmagman commented Jul 14, 2020

@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

@bhavyalatha26
Copy link

Ok thank you @jmagman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: existing-apps Integration with existing apps via the add-to-app flow P3 Issues that are less important to the Flutter project platform-ios iOS applications specifically team-ios Owned by iOS platform team tool Affects the "flutter" command-line tool. See also t: labels. triaged-ios Triaged by iOS platform team
Projects
Add-to-app - iOS tool review
  
Engineer reviewed
Development

No branches or pull requests

4 participants