【问题标题】:Passing dart environment variables in xcodebuild build-for-testing command在 xcodebuild build-for-testing 命令中传递 dart 环境变量
【发布时间】:2023-01-31 01:02:56
【问题描述】:
我正在尝试在 firebase 测试实验室上运行我的 flutter 集成测试。因此,我使用 dart 环境变量来设置我的登录凭据。要设置 ios 测试版本,我需要运行以下命令:
xcodebuild -workspace Runner.xcworkspace -scheme Runner -config Flutter/Release.xcconfig -derivedDataPath ../build/ios_integ -sdk iphoneos build-for-testing
我现在的问题是如何在此命令中设置 dart 环境变量?当我将变量作为 base64 字符串 -Pdart-defines="${BASE64_STRING}" 传递时,它在 android gradle 任务上起作用。但这在 iOS 上对我不起作用。
【问题讨论】:
标签:
ios
xcode
flutter
flutter-integration-test
【解决方案1】:
在仅配置模式下运行flutter build ios,传递你的 dart 定义:
flutter build ios --config-only -t integration_test/example_test.dart --debug --dart-define MY_KEY=MY_VALUE
如果成功,您应该能够在 Flutter/Generated.xcconfig 文件(以 base64 编码)中看到您的 dart 定义:
$ cat ios/Flutter/Generated.xcconfig | grep DART_DEFINES
DART_DEFINES=TVlfS0VZPU1ZX1ZBTFVF
$ printf 'TVlfS0VZPU1ZX1ZBTFVF' | base64 -d
MY_KEY=MY_VALUE
如果您现在执行xcodebuild build-for-testing,dart 定义将被编译到您的应用程序中。