I’m building a Flutter app and using --dart-define to pass environment-specific variables like ENV, x-api-key, or base URLs. This works perfectly for Android using:
flutter build apk --dart-define=ENV=prod
For iOS, I can build the app and generate a .ipa using:
flutter build ipa --dart-define=ENV=prod
Till Now
There was no environment variable setup. So I used to deploy app using Xcode > Product > Archive which builds the app, and opens the Organizer window. From there, I can choose distribution methods such as TestFlight, App Store, or export the .ipa as seen in the image. However, this method does not include my –dart-define variables like ENV=prod, which are critical for my app’s configuration
.
If I use flutter build ipa --dart-define=ENV=prod to build the .ipa, I have to use Transporter app to upload the .ipa. But it does not give me as many option as I get in XCode shown I the image.
My Question:
How can I:
Use Xcode to build the iOS app and still include the –dart-define environment variables, like ENV=prod?
OR, is there a way to get the same App Store distribution options (like Organizer window) after building via flutter build ipa?
Any guidance on how to bridge this gap between Flutter CLI builds and the Xcode Organizer flow would be really helpful.
Thanks!