首页 > 解决方案 > 通过传递环境变量 Xcode 更改应用程序名称

问题描述

我想要做的是通过在使用构建应用程序时传递环境变量来更改应用程序名称flutter run --dart-define=COMPANY_NAME="FIAMM"

在我的 Xcode 项目 -> 目标 -> 构建设置 -> 产品名称中:

产品名称设置

如果我运行flutter run --dart-define=COMPANY_NAME="FIAMM",编译器会显示此错误:

** BUILD FAILED **


Xcode's output:
↳
  note: Using new build system
  note: Planning
  note: Build preparation complete
  note: Building targets in parallel
  error: Multiple commands produce
  '/Users/fabiosacilotto/Flutter/topclass_wip/build/ios/Debug-iphoneos/.app':
  1) Target 'Runner' has link command with output
  '/Users/fabiosacilotto/Flutter/topclass_wip/build/ios/Debug-iphoneos/.app'
  2) Target 'Runner' has create directory command with output
  '/Users/fabiosacilotto/Flutter/topclass_wip/build/ios/Debug-iphoneos/.app'

/Users/fabiosacilotto/Flutter/topclass_wip/ios/Pods/Pods.xcodeproj: warning:
The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but
the range of supported deployment target versions is 9.0 to 15.0.99. (in
target 'Flutter' from project 'Pods')
warning: duplicate output file
'/Users/fabiosacilotto/Flutter/topclass_wip/build/ios/Debug-iphoneos/.app'
on task: MkDir
/Users/fabiosacilotto/Flutter/topclass_wip/build/ios/Debug-iphoneos/.app (in
target 'Runner' from project 'Runner')

Could not build the precompiled application for the device.

It appears that your application still contains the default signing identifier.
Try replacing 'com.example' with your signing id in Xcode:
open iOS/Runner.xcworkspace

相反,如果我在之前/之后添加一些东西$(COMPANY_NAME),编译器会构建应用程序而不会出现任何错误。

有没有办法让它构建应用程序只留下$(COMPANY_NAME)

标签: iosxcodeflutterenvironment-variables

解决方案


推荐阅读