Repository navigation
"flutter run" fails with "Target aot_assembly_release failed: Exception: release/profile builds are only supported for physical devices. attempted to build for simulator." #85643
Description
Activity
User is running straight
flutter run -vwhich is choosing an iOS simulator. However, even though the Configuration is Debug (export CONFIGURATION\=Debug) it's passing-dBuildMode=releaseto assemble:/Users/adeel/flutter/bin/flutter --verbose assemble --no-version-check --output=/Users/adeel/projects/misoapp/build/ios/Debug-iphonesimulator/ -dTargetPlatform=ios -dTargetFile=/Users/adeel/projects/misoapp/lib/main.dart -dBuildMode=release -dIosArchs=x86_64 -dSdkRoot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk -dSplitDebugInfo= -dTreeShakeIcons=false -dTrackWidgetCreation=true -dDartObfuscation=false -dEnableBitcode= -dCodesignIdentity=- --ExtraGenSnapshotOptions= --DartDefines=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ== --ExtraFrontEndOptions= release_ios_bundle_flutter_assetsFailure is:
[ +7 ms] Target aot_assembly_release failed: Exception: release/profile builds are only supported for physical devices. attempted to build for simulator.Odd, I really wouldn't have expected this problem unless
FLUTTER_BUILD_MODEis set, which it's not.flutter/packages/flutter_tools/bin/xcode_backend.sh
Lines 101 to 107 in d79295a
local build_mode="$(ParseFlutterBuildMode)" local artifact_variant="unknown" case "$build_mode" in release ) artifact_variant="ios-release";; profile ) artifact_variant="ios-profile";; debug ) artifact_variant="ios";; esac
flutter/packages/flutter_tools/bin/xcode_backend.sh
Lines 41 to 50 in d79295a
ParseFlutterBuildMode() { # Use FLUTTER_BUILD_MODE if it's set, otherwise use the Xcode build configuration name # This means that if someone wants to use an Xcode build config other than Debug/Profile/Release, # they _must_ set FLUTTER_BUILD_MODE so we know what type of artifact to build. local build_mode="$(echo "${FLUTTER_BUILD_MODE:-${CONFIGURATION}}" | tr "[:upper:]" "[:lower:]")" case "$build_mode" in *release*) build_mode="release";; *profile*) build_mode="profile";; *debug*) build_mode="debug";;
-dBuildMode=${build_mode} \ @realadeel What's the output of:
$ cd /Users/adeel/flutter $ git statusCan you also attach
/Users/adeel/flutter/packages/flutter_tools/bin/xcode_backend.sh?- addedwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
on Jun 30, 2021 @jmagman
Adeels-MacBook-Pro-2:flutter adeel$ git status
On branch stable
Your branch is up to date with 'origin/stable'.nothing to commit, working tree clean
#!/usr/bin/env bash # Copyright 2014 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # Exit on error set -e RunCommand() { if [[ -n "$VERBOSE_SCRIPT_LOGGING" ]]; then echo "♦ $*" fi "$@" return $? } # When provided with a pipe by the host Flutter build process, output to the # pipe goes to stdout of the Flutter build process directly. StreamOutput() { if [[ -n "$SCRIPT_OUTPUT_STREAM_FILE" ]]; then echo "$1" > $SCRIPT_OUTPUT_STREAM_FILE fi } EchoError() { echo "$@" 1>&2 } AssertExists() { if [[ ! -e "$1" ]]; then if [[ -h "$1" ]]; then EchoError "The path $1 is a symlink to a path that does not exist" else EchoError "The path $1 does not exist" fi exit -1 fi return 0 } ParseFlutterBuildMode() { # Use FLUTTER_BUILD_MODE if it's set, otherwise use the Xcode build configuration name # This means that if someone wants to use an Xcode build config other than Debug/Profile/Release, # they _must_ set FLUTTER_BUILD_MODE so we know what type of artifact to build. local build_mode="$(echo "${FLUTTER_BUILD_MODE:-${CONFIGURATION}}" | tr "[:upper:]" "[:lower:]")" case "$build_mode" in *release*) build_mode="release";; *profile*) build_mode="profile";; *debug*) build_mode="debug";; *) EchoError "========================================================================" EchoError "ERROR: Unknown FLUTTER_BUILD_MODE: ${build_mode}." EchoError "Valid values are 'Debug', 'Profile', or 'Release' (case insensitive)." EchoError "This is controlled by the FLUTTER_BUILD_MODE environment variable." EchoError "If that is not set, the CONFIGURATION environment variable is used." EchoError "" EchoError "You can fix this by either adding an appropriately named build" EchoError "configuration, or adding an appropriate value for FLUTTER_BUILD_MODE to the" EchoError ".xcconfig file for the current build configuration (${CONFIGURATION})." EchoError "========================================================================" exit -1;; esac echo "${build_mode}" } BuildApp() { local project_path="${SOURCE_ROOT}/.." if [[ -n "$FLUTTER_APPLICATION_PATH" ]]; then project_path="${FLUTTER_APPLICATION_PATH}" fi local target_path="lib/main.dart" if [[ -n "$FLUTTER_TARGET" ]]; then target_path="${FLUTTER_TARGET}" fi local derived_dir="${SOURCE_ROOT}/Flutter" if [[ -e "${project_path}/.ios" ]]; then derived_dir="${project_path}/.ios/Flutter" fi local bundle_sksl_path="" if [[ -n "$BUNDLE_SKSL_PATH" ]]; then bundle_sksl_path="-iBundleSkSLPath=${BUNDLE_SKSL_PATH}" fi # Default value of assets_path is flutter_assets local assets_path="flutter_assets" # The value of assets_path can set by add FLTAssetsPath to # AppFrameworkInfo.plist. if FLTAssetsPath=$(/usr/libexec/PlistBuddy -c "Print :FLTAssetsPath" "${derived_dir}/AppFrameworkInfo.plist" 2>/dev/null); then if [[ -n "$FLTAssetsPath" ]]; then assets_path="${FLTAssetsPath}" fi fi # Use FLUTTER_BUILD_MODE if it's set, otherwise use the Xcode build configuration name # This means that if someone wants to use an Xcode build config other than Debug/Profile/Release, # they _must_ set FLUTTER_BUILD_MODE so we know what type of artifact to build. local build_mode="$(ParseFlutterBuildMode)" local artifact_variant="unknown" case "$build_mode" in release ) artifact_variant="ios-release";; profile ) artifact_variant="ios-profile";; debug ) artifact_variant="ios";; esac # Warn the user if not archiving (ACTION=install) in release mode. if [[ "$ACTION" == "install" && "$build_mode" != "release" ]]; then echo "warning: Flutter archive not built in Release mode. Ensure FLUTTER_BUILD_MODE \ is set to release or run \"flutter build ios --release\", then re-run Archive from Xcode." fi local framework_path="${FLUTTER_ROOT}/bin/cache/artifacts/engine/${artifact_variant}" local flutter_engine_flag="" local local_engine_flag="" local flutter_framework="${framework_path}/Flutter.xcframework" if [[ -n "$FLUTTER_ENGINE" ]]; then flutter_engine_flag="--local-engine-src-path=${FLUTTER_ENGINE}" fi if [[ -n "$LOCAL_ENGINE" ]]; then if [[ $(echo "$LOCAL_ENGINE" | tr "[:upper:]" "[:lower:]") != *"$build_mode"* ]]; then EchoError "========================================================================" EchoError "ERROR: Requested build with Flutter local engine at '${LOCAL_ENGINE}'" EchoError "This engine is not compatible with FLUTTER_BUILD_MODE: '${build_mode}'." EchoError "You can fix this by updating the LOCAL_ENGINE environment variable, or" EchoError "by running:" EchoError " flutter build ios --local-engine=ios_${build_mode}" EchoError "or" EchoError " flutter build ios --local-engine=ios_${build_mode}_unopt" EchoError "========================================================================" exit -1 fi local_engine_flag="--local-engine=${LOCAL_ENGINE}" flutter_framework="${FLUTTER_ENGINE}/out/${LOCAL_ENGINE}/Flutter.xcframework" fi local bitcode_flag="" if [[ "$ENABLE_BITCODE" == "YES" && "$ACTION" == "install" ]]; then bitcode_flag="true" fi # TODO(jmagman): use assemble copied engine in add-to-app. if [[ -e "${project_path}/.ios" ]]; then RunCommand rm -rf -- "${derived_dir}/engine/Flutter.framework" RunCommand cp -r -- "${flutter_framework}" "${derived_dir}/engine" fi RunCommand pushd "${project_path}" > /dev/null local verbose_flag="" if [[ -n "$VERBOSE_SCRIPT_LOGGING" ]]; then verbose_flag="--verbose" fi local performance_measurement_option="" if [[ -n "$PERFORMANCE_MEASUREMENT_FILE" ]]; then performance_measurement_option="--performance-measurement-file=${PERFORMANCE_MEASUREMENT_FILE}" fi local code_size_directory="" if [[ -n "$CODE_SIZE_DIRECTORY" ]]; then code_size_directory="-dCodeSizeDirectory=${CODE_SIZE_DIRECTORY}" fi local codesign_identity_flag="" if [[ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" && "${CODE_SIGNING_REQUIRED:-}" != "NO" ]]; then codesign_identity_flag="-dCodesignIdentity=${EXPANDED_CODE_SIGN_IDENTITY}" fi RunCommand "${FLUTTER_ROOT}/bin/flutter" \ ${verbose_flag} \ ${flutter_engine_flag} \ ${local_engine_flag} \ assemble \ --no-version-check \ --output="${BUILT_PRODUCTS_DIR}/" \ ${performance_measurement_option} \ -dTargetPlatform=ios \ -dTargetFile="${target_path}" \ -dBuildMode=${build_mode} \ -dIosArchs="${ARCHS}" \ -dSdkRoot="${SDKROOT}" \ -dSplitDebugInfo="${SPLIT_DEBUG_INFO}" \ -dTreeShakeIcons="${TREE_SHAKE_ICONS}" \ -dTrackWidgetCreation="${TRACK_WIDGET_CREATION}" \ -dDartObfuscation="${DART_OBFUSCATION}" \ -dEnableBitcode="${bitcode_flag}" \ "${codesign_identity_flag}" \ ${bundle_sksl_path} \ ${code_size_directory} \ --ExtraGenSnapshotOptions="${EXTRA_GEN_SNAPSHOT_OPTIONS}" \ --DartDefines="${DART_DEFINES}" \ --ExtraFrontEndOptions="${EXTRA_FRONT_END_OPTIONS}" \ "${build_mode}_ios_bundle_flutter_assets" if [[ $? -ne 0 ]]; then EchoError "Failed to package ${project_path}." exit -1 fi StreamOutput "done" StreamOutput " └─Compiling, linking and signing..." RunCommand popd > /dev/null echo "Project ${project_path} built and packaged successfully." return 0 } # Adds the App.framework as an embedded binary and the flutter_assets as # resources. EmbedFlutterFrameworks() { # Embed App.framework from Flutter into the app (after creating the Frameworks directory # if it doesn't already exist). local xcode_frameworks_dir="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" RunCommand mkdir -p -- "${xcode_frameworks_dir}" RunCommand rsync -av --delete --filter "- .DS_Store" "${BUILT_PRODUCTS_DIR}/App.framework" "${xcode_frameworks_dir}" # Embed the actual Flutter.framework that the Flutter app expects to run against, # which could be a local build or an arch/type specific build. RunCommand rsync -av --delete --filter "- .DS_Store" "${BUILT_PRODUCTS_DIR}/Flutter.framework" "${xcode_frameworks_dir}/" AddObservatoryBonjourService } # Add the observatory publisher Bonjour service to the produced app bundle Info.plist. AddObservatoryBonjourService() { local build_mode="$(ParseFlutterBuildMode)" # Debug and profile only. if [[ "${build_mode}" == "release" ]]; then return fi local built_products_plist="${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}" if [[ ! -f "${built_products_plist}" ]]; then # Very occasionally Xcode hasn't created an Info.plist when this runs. # The file will be present on re-run. echo "${INFOPLIST_PATH} does not exist. Skipping _dartobservatory._tcp NSBonjourServices insertion. Try re-building to enable \"flutter attach\"." return fi # If there are already NSBonjourServices specified by the app (uncommon), insert the observatory service name to the existing list. if plutil -extract NSBonjourServices xml1 -o - "${built_products_plist}"; then RunCommand plutil -insert NSBonjourServices.0 -string "_dartobservatory._tcp" "${built_products_plist}" else # Otherwise, add the NSBonjourServices key and observatory service name. RunCommand plutil -insert NSBonjourServices -json "[\"_dartobservatory._tcp\"]" "${built_products_plist}" fi # Don't override the local network description the Flutter app developer specified (uncommon). # This text will appear below the "Your app would like to find and connect to devices on your local network" permissions popup. if ! plutil -extract NSLocalNetworkUsageDescription xml1 -o - "${built_products_plist}"; then RunCommand plutil -insert NSLocalNetworkUsageDescription -string "Allow Flutter tools on your computer to connect and debug your application. This prompt will not appear on release builds." "${built_products_plist}" fi } # Main entry point. if [[ $# == 0 ]]; then # Named entry points were introduced in Flutter v0.0.7. EchoError "error: Your Xcode project is incompatible with this version of Flutter. Run \"rm -rf ios/Runner.xcodeproj\" and \"flutter create .\" to regenerate." exit -1 else case $1 in "build") BuildApp ;; "thin") # No-op, thinning is handled during the bundle asset assemble build target. ;; "embed") EmbedFlutterFrameworks ;; "embed_and_thin") # Thinning is handled during the bundle asset assemble build target, so just embed. EmbedFlutterFrameworks ;; "test_observatory_bonjour_service") # Exposed for integration testing only. AddObservatoryBonjourService ;; esac fiHuh, yeah that looks clean to me. Can't spot how
CONFIGURATION=Debugis resulting in-dBuildMode=release...Reacted by Adeel Ahmad, Dominik Roszkowski, Bartek Pacia and Fabian TerhorstReacted by charlieww and Fabian Terhorst- removedwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
on Jul 1, 2021 - addedt: xcode"xcodebuild" on iOS and general Xcode project management"xcodebuild" on iOS and general Xcode project managementtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.P2Important issues not at the top of the work listImportant issues not at the top of the work list
on Jul 1, 2021 Huh, yeah that looks clean to me. Can't spot how
CONFIGURATION=Debugis resulting in-dBuildMode=release...How do you fix it ? i have this issue two and do not know how to fix it... it's stuck me for a long time
Reacted by Oğuz, Nguyen Thanh Hai, Argen Zhukeev, John Wehrle, Nyoman Putra Utama, harshitkumawat20, ViktorKirjanov, Verry and Aizan SagheerFix for me was removing
export FLUTTER_BUILD_MODE=Releasefrom the~/.zshrc
This ENV was overriding the command-line flags so builds would always be release buildsReacted by 开水白菜Reacted by AlfreedomReacted by Kk_xx and Aizan SagheerNot sure if it's relevant, but I came across the same issue and tried archiving the app via Xcode. The console logs the following error:
This binary was built with the incorrect architecture to run on this machine. Flutter requires the Rosetta translation environment. If you are on an ARM Mac, try running: sudo softwareupdate --install-rosetta --agree-to-licenseAnd then I found this issue which mentions native build engine support for ARM Macs. But at the moment this issue is still open and the implementation not done. So I guess, maybe we just have to wait
Reacted by Firooz Smart and João Felipe SantanaReacted by Firooz Smart and João Felipe Santana- addedteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtriaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool team
on Jul 8, 2023 sudo softwareupdate --install-rosetta --agree-to-licenseRun this command. It works me.Reacted by takei-milabo and Gowtham SooryarajReacted by VinothRishabhApologies for the long post, but hope this helps people avoid the hours of struggle (some of it self-inflicted).
I encountered this same error while attempting to get flavors running on an iOS Simulator (iphone 16, iOS 18.1) while following the
Flutter Flavors GuideSome additional context is that I was also setting this up in conjunction with setting up Firebase for multiple environments (Note: This guide is linked on the official Flutter Flavors Guide)
I finally have a setup that works across flavors. I've called out any particular changes I may have initially overlooked or any deviations from the two docs I used.
- I created the schemes by duplicating the existing scheme from the Manage Schemes window
- This I believe is mentioned in the guide but it's important to ensure that your xcode scheme matches the flavor name (ensure case sensitive matching).
For example, your xcode scheme should be called "dev" if your flavor is "dev" (case sensitive). I had made the mistake of naming my scheme "Dev" instead of matching it to flavor "dev".
I believe this was my major blunder, but the associated errors did not immediately lead me to finding out that this was the issue.
I will outline additional things I checked/modified, but those might not have as much bearing.
- This is mentioned in the guide but ensure that the flavor build configs are using the default schemes
- When setting Product Name in those instructions in Step 2, ensure you are doing so on the Project and not the Target. The Target has to remain as Runner.
- The instructions in Step 5 display an image for your scheme configurations that seems to set every setting to "Debug-{flavor}" (in the case of the instructions, it's "Debug-free".
However, I mirrored the scheme settings that were already present for the default scheme and set the corresponding build configuration for my flavor

- I did run (on my M1 MBP)
sudo softwareupdate --install-rosetta --agree-to-license`
and received an error
2024-12-04 09:06:02.684 softwareupdate[76958:3274780] Package Authoring Error: 062-58681: Package reference com.apple.pkg.RosettaUpdateAuto is missing installKBytes attribute
which I believe you can ignore
- I updated my Podfile as follows

- added a commit that references this issue
on Jan 24, 2025 - added a commit that references this issue
on Jan 24, 2025 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Feb 7, 2025
I've been having the same issue on an existing app and then just tried a completely fresh app and getting the same issue. The issue started happening after upgrading to 2.2.2 but downgrading has not helped. Also, Android is fine.
Logs below. Project attached here.
misoapp.zip
flutter doctor -v
Adeels-MacBook-Pro-2:misoapp adeel$ flutter doctor -v [✓] Flutter (Channel stable, 2.2.2, on macOS 11.4 20F71 darwin-x64, locale en-US) • Flutter version 2.2.2 at /Users/adeel/flutter • Framework revision d79295a (3 weeks ago), 2021-06-11 08:56:01 -0700 • Engine revision 91c9fc8fe0 • Dart version 2.13.3[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/adeel/Library/Android/sdk
• Platform android-30, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5, Build version 12E262
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 49.0.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.57.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.23.0
[✓] Connected device (3 available)
• iPhone 12 Pro Max (mobile) • 520CFDE9-DF8D-44DD-A634-3AC152A4117D • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
• macOS (desktop) • macos • darwin-x64 • macOS 11.4 20F71 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.114
• No issues found!
Results of flutter run -v:
flutter-run.txt
(Log was too long to paste)
Originally posted by @realadeel in #85197 (comment)