Repository navigation
CI non-debug release builds "Failed to find correct customLLDBInitFile" #172170
Description
Steps to reproduce
I'm not sure if this is sufficient to reproduce the problem or not, but here is what I did with my existing project:
- Setup a multi-flavored (Dev, Prod) flutter project along with the associated Schemes in xcode. The Dev scheme supports debugging while the Prod scheme does not.
- Upgrade to latest MacOS/XCode
- Upgrade Flutter from 3.27.4 to 3.32.6
- Build your app (Prod scheme that does not support debugging) that was previously "working fine".
- Notice the error reported: "An error occurred when adding LLDB Init File: Exception: Failed to find correct customLLDBInitFile in LaunchAction for the Scheme in /Users/user/projects/flutter_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Prod.xcscheme."
Luckily, the Dev.xcscheme and Prod.xcscheme files are version controlled, so I can see that something made changes to the Dev.xcscheme but not the Prod.xcscheme. The <TestAction> element in the Dev.xcscheme file was modified (I don't know if this was by xcode or by flutter) such that it now contains the following attribute:
Before upgrade:
<TestAction
buildConfiguration = "Debug-Dev"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>After upgrade
<TestAction
buildConfiguration = "Debug-Dev"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>Similar changes were made to the <LaunchAction> element except the "selectedLauncherIdentifier" was also changed from Xcode.IDEFoundation.Launcher.PosixSpawn to Xcode.DebuggerFoundation.Launcher.LLDB and the customLLDBInitFile was also added. I don't include the LaunchAction snippets here for brevity, and to exclude project identifiers.
I'm not sure what caused this change to be made. I did not consciously or purposefully make this change. But, this change does cause me stupor of thought and questions. For example, Dev.xcsheme and Prod.xcscheme are committed to version control and now Dev.xcsheme references a resource that I have explicitly added to .gitignore (ie: Flutter/ephemeral/). Maybe I should not be doing that? flutter_lldbinit is an auto generated script (by flutter?) so should flutter_lldbinit be added or excluded from version control? Chat GPT suggests it should be excluded from version control, but it doesn't make sense to me to have Dev.xcsheme (which is version controlled) reference a resource that is excluded from version control. I guess I'm getting side tracked explaining some of my questions and confusion about this customLLDBInitFile configuration. I think it would be really helpful to have good documentation regarding these settings and explicitly stating what should and should not be included in version control.
But, back to this issue. My Prod.xcscheme does not support debugging. That should be optimized for production. So, why does the tool (https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/migrations/lldb_init_migration.dart#L229) require the customLLDBInitFile for a shared scheme that does not enable debugging?
Expected results
Build your app (Prod scheme that does not support debugging) successfully without reporting that "An error occurred when adding LLDB Init File...".
Should the LLDB Init File be part of the build process if the scheme does not have debugging enabled?
Actual results
An error occurred when adding LLDB Init File:
Exception: Failed to find correct customLLDBInitFile in LaunchAction for the Scheme in /Users/user/projects/flutter_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Prod.xcscheme.
Code sample
Code sample
N/AScreenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
N/AFlutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.32.6, on macOS 15.5 24F74 darwin-arm64, locale en-US) [403ms]
• Flutter version 3.32.6 on channel stable at /Users/user/fvm/versions/3.32.6
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 077b4a4ce1 (7 days ago), 2025-07-08 13:31:08 -0700
• Engine revision 72f2b18bb0
• Dart version 3.8.1
• DevTools version 2.45.1
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [1,121ms]
• Android SDK at /Users/user/Library/Android/sdk
• Platform android-35, build-tools 35.0.0
• ANDROID_SDK_ROOT = /Users/user/Library/Android/sdk
• Java binary at: /Users/user/.sdkman/candidates/java/17.0.13-tem/bin/java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment Temurin-17.0.13+11 (build 17.0.13+11)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [759ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16F6
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [79ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2025.1) [79ms]
• Android Studio at /Users/user/Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
[✓] IntelliJ IDEA Ultimate Edition (version 2025.1.3) [78ms]
• IntelliJ at /Users/user/Applications/IntelliJ IDEA Ultimate.app
• Flutter plugin version 86.0.2
• Dart plugin version 251.27623
[✓] VS Code (version 1.100.3) [10ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.112.0
[✓] Connected device (4 available) [6.5s]
<redacted>
[✓] Network resources [246ms]
• All expected network resources are available.
• No issues found!
Activity
tirth-patel-nc commentedon Jul 16, 2025
from #164344
thanks for the report. @thermoworker could you please share a minimal reproducible sample in a public repo that we can clone and test? that would help us verify the issue more easily.
maxakak1998 commentedon Jul 17, 2025
Same for me. I just upgraded from 3.29 to the latest version. The project seems still working fine.
nekooooo0203 commentedon Aug 1, 2025
@tirth-patel-nc
Hello,
I created a sample public repository, please check it by changing flutter version.
https://github.com/nekooooo0203/flavor-sample
Version : Upgrading Flutter to 3.32.8 from 3.29.2
Sample repository error message
In original repository, when I run app, ios/Flutter/ephemeral/ 2 files created, and has this error message.
Original repository error message
original repo Production.xcscheme
original repo ios/Flutter/ephemeralflutter_lldb_helper.py
# # Generated file, do not edit. #import lldb
def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict):
"""Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages."""
base = frame.register["x0"].GetValueAsAddress()
page_len = frame.register["x1"].GetValueAsUnsigned()
def __lldb_init_module(debugger: lldb.SBDebugger, _):
target = debugger.GetDummyTarget()
# Caveat: must use BreakpointCreateByRegEx here and not
# BreakpointCreateByName. For some reasons callback function does not
# get carried over from dummy target for the later.
bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$")
bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(name))
bp.SetAutoContinue(True)
print("-- LLDB integration loaded --")
original repo ios/Flutter/ephemeralflutter_lldbinit
# # Generated file, do not edit. #command script import --relative-to-command-file flutter_lldb_helper.py
only Development.xcscheme has added these line, not in Production.xcscheme
< TestAction customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit". // added < LaunchAction customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit". // addedtirth-patel-nc commentedon Aug 11, 2025
@nekooooo0203 I tried building your repo, it worked fine for me on latest master.
saitou-yuka commentedon Aug 12, 2025
@tirth-patel-nc
Thank you for checking repo.
I actually have no idea why this is happening.
Could you check the video I uploaded on gigafile, which recorded from version changing before and after.
https://8.gigafile.nu/1120-m501c16104574dae4f5d6cdc61d8882c9
is this my environment making problem....?
davidmigloz commentedon Aug 18, 2025
After a long debugging session, it seems the underlying issue was that a Flutter migration script, responsible for adding a necessary
customLLDBInitFilesetting for debugging, was failing. This script was designed to find a specific line in the.xcschemefiles (selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB") and insert the new setting after it.However, in my
test.xcschemeandprod.xcschemefiles, theselectedLauncherIdentifierhad a different value (selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"). Because the script couldn't find the exact line it was looking for, the replacement failed. The script then proceeded to a validation step, which checked if thecustomLLDBInitFilewas correctly added. Since it wasn't, the validation failed and threw the "Failed to find correct customLLDBInitFile" error.To fix this, I updated the
TestActionandLaunchActionin bothtest.xcschemeandprod.xcschemeby correcting theselectedDebuggerIdentifierandselectedLauncherIdentifiervalues. This allowed the Flutter migration script to successfully inject thecustomLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"line, aligning the files with what the Flutter migration script expects.Rather than relying on a simple string replacement, the script should be updated to implement a more robust solution.
tirth-patel-nc commentedon Aug 18, 2025
@davidmigloz could you please share the exact steps to replicate the problem on our end?
tirth-patel-nc commentedon Aug 18, 2025
friendly tip: if you face a similar issue and the existing one doesn’t have clear steps to reproduce, please file a new issue. it helps us track and resolve things more effectively. thank you!
davidmigloz commentedon Aug 18, 2025
ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme.LaunchActionandTestActionsections and change theselectedLauncherIdentifiervalue to"Xcode.IDEFoundation.Launcher.PosixSpawn".flutter run. The build will fail with theFailed to find correct customLLDBInitFileerror.Root cause
The problem is in the
_migrateSchemefunction within thelldb_init_migration.dartscript.This code uses a hardcoded string replacement (
replaceAll). It fails if theselectedLauncherIdentifierhas any other value.The fix is to parse the XML properly instead of relying on string replacement. The script should locate the
<LaunchAction>and<TestAction>XML nodes and then intelligently add or update the necessary attributes (selectedDebuggerIdentifier,selectedLauncherIdentifier, andcustomLLDBInitFile) to ensure the migration is successful regardless of the initial scheme configuration.Let me know if you'd prefer I create a new issue with these steps for easier tracking.
tirth-patel-nc commentedon Aug 21, 2025
@davidmigloz thanks for the steps. I followed them and tested on a simulator on previous stable (3.32.8), latest stable (3.35.1) & latest master, I couldn't replicate it.
Screen.Recording.2025-08-21.at.12.49.30.PM.mov
davidmigloz commentedon Aug 21, 2025
Hey @tirth-patel-nc,
Thanks for taking the time to test this!
I reviewed the recording, and I think I see why the issue didn't reproduce. In the video, the
Runner.xcschemefile already contains thecustomLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"line from the very beginning.Because that line was already present, the migration script correctly determined that the project was already migrated and didn't need to run. The bug I encountered only happens when the script needs to add that line but can't because of the unexpected
selectedLauncherIdentifier.To trigger the failure, the starting state of the
Runner.xcschemefile must:customLLDBInitFileline.selectedLauncherIdentifierset to"Xcode.IDEFoundation.Launcher.PosixSpawn".tirth-patel-nc commentedon Aug 22, 2025
@davidmigloz thanks for sharing the updated steps. I followed them and was able to build successfully on latest master, though I still see an error in the console.
davidmigloz commentedon Aug 22, 2025
Thanks for testing it again! That error message you see in the console is exactly the bug I was reporting. The migration script is failing to modify the scheme file.
28 remaining items
davidmigloz commentedon Aug 25, 2025
Thanks for the follow-up.
That makes sense. The migration script that causes this issue was introduced in Flutter
3.32.0.While new projects are created with the correct template, my project is over 5 years old. I don't recall ever changing the
selectedLauncherIdentifiermanually, so I believe Flutter projects were using that value at some point in time.A quick search in the Flutter repository shows that the
Xcode.IDEFoundation.Launcher.PosixSpawnvalue has been used:flutter/dev/benchmarks/imitation_game_swiftui/hello_world_swiftui.xcodeproj/xcshareddata/xcschemes/hello_world_swiftui.xcscheme
Line 29 in ddfbad8
So, while the reproduction steps require modifying a new project, they represent the real-world state of older Flutter projects.
Make every LLDB Init error message actionable (#174726)
fix bug in flutter Runner scheme
Make every LLDB Init error message actionable (flutter#174726)
github-actions commentedon Sep 19, 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.Make every LLDB Init error message actionable (flutter#174726)
Make every LLDB Init error message actionable (flutter#174726)
Make every LLDB Init error message actionable (#174726)