Skip to content

CI non-debug release builds "Failed to find correct customLLDBInitFile" #172170

Closed

Description

@thermoworker

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:

  1. 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.
  2. Upgrade to latest MacOS/XCode
  3. Upgrade Flutter from 3.27.4 to 3.32.6
  4. Build your app (Prod scheme that does not support debugging) that was previously "working fine".
  5. 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/A

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
N/A

Flutter 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

  1. tirth-patel-nc commented on Jul 16, 2025

    @tirth-patel-nc
    Member

    from #164344

    During flutter assemble, if the project doesn't have an LLDB Init File set for any schemes, it'll throw an error if running in debug mode with an iOS 18.4+ device.

    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.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 16, 2025
  3. maxakak1998 commented on Jul 17, 2025

    @maxakak1998

    Same for me. I just upgraded from 3.29 to the latest version. The project seems still working fine.

  4. nekooooo0203 commented on Aug 1, 2025

    @nekooooo0203

    @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

    An error occurred when adding LLDB Init File:
    Exception: Unable to get scheme file for Development.
    

    In original repository, when I run app, ios/Flutter/ephemeral/ 2 files created, and has this error message.
    Original repository error message

    An error occurred when adding LLDB Init File:
    Exception: Failed to find correct customLLDBInitFile in LaunchAction for the Scheme in /Users/kkaneda/dev/ChatApp/ios/Runner.xcodeproj/xcshareddata/xcschemes/Production.xcscheme.
    
    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()

    # Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the
    # first page to see if handled it correctly. This makes diagnosing
    # misconfiguration (e.g. missing breakpoint) easier.
    data = bytearray(page_len)
    data[0:8] = b'IHELPED!'
    
    error = lldb.SBError()
    frame.GetThread().GetProcess().WriteMemory(base, data, error)
    if not error.Success():
        print(f'Failed to write into {base}[+{page_len}]', error)
        return
    

    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". // added
  5. tirth-patel-nc commented on Aug 11, 2025

    @tirth-patel-nc
    Member
    Image

    @nekooooo0203 I tried building your repo, it worked fine for me on latest master.

  6. saitou-yuka commented on Aug 12, 2025

    @saitou-yuka

    @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....?

  7. davidmigloz commented on Aug 18, 2025

    @davidmigloz
    Contributor

    After a long debugging session, it seems the underlying issue was that a Flutter migration script, responsible for adding a necessary customLLDBInitFile setting for debugging, was failing. This script was designed to find a specific line in the .xcscheme files (selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB") and insert the new setting after it.

    However, in my test.xcscheme and prod.xcscheme files, the selectedLauncherIdentifier had 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 the customLLDBInitFile was correctly added. Since it wasn't, the validation failed and threw the "Failed to find correct customLLDBInitFile" error.

    To fix this, I updated the TestAction and LaunchAction in both test.xcscheme and prod.xcscheme by correcting the selectedDebuggerIdentifier and selectedLauncherIdentifier values. This allowed the Flutter migration script to successfully inject the customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit" line, aligning the files with what the Flutter migration script expects.

    --- ios/Runner.xcodeproj/xcshareddata/xcschemes/test.xcscheme
    +++ ios/Runner.xcodeproj/xcshareddata/xcschemes/test.xcscheme
    @@ -42,8 +42,9 @@
        </BuildAction>
        <TestAction
           buildConfiguration = "Release-test"
    -      selectedDebuggerIdentifier = ""
    -      selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
    +      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
    +      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
    +      customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
           shouldUseLaunchSchemeArgsEnv = "YES">
           <MacroExpansion>
              <BuildableReference
    @@ -59,8 +60,9 @@
        </TestAction>
        <LaunchAction
           buildConfiguration = "Release-test"
    -      selectedDebuggerIdentifier = ""
    -      selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
    +      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
    +      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
    +      customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
           launchStyle = "0"
           useCustomWorkingDirectory = "NO"
           ignoresPersistentStateOnLaunch = "NO"
    --- ios/Runner.xcodeproj/xcshareddata/xcschemes/prod.xcscheme
    +++ ios/Runner.xcodeproj/xcshareddata/xcschemes/prod.xcscheme
    @@ -42,8 +42,8 @@
        </BuildAction>
        <TestAction
           buildConfiguration = "Release-prod"
    -      selectedDebuggerIdentifier = ""
    -      selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
    +      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
    +      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
           shouldUseLaunchSchemeArgsEnv = "YES">
           <MacroExpansion>
              <BuildableReference
    @@ -59,8 +59,8 @@
        </TestAction>
        <LaunchAction
           buildConfiguration = "Release-prod"
    -      selectedDebuggerIdentifier = ""
    -      selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
    +      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
    +      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
           launchStyle = "0"
           useCustomWorkingDirectory = "NO"
           ignoresPersistentStateOnLaunch = "NO"

    Rather than relying on a simple string replacement, the script should be updated to implement a more robust solution.

  8. tirth-patel-nc commented on Aug 18, 2025

    @tirth-patel-nc
    Member

    @davidmigloz could you please share the exact steps to replicate the problem on our end?

  9. tirth-patel-nc commented on Aug 18, 2025

    @tirth-patel-nc
    Member

    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!

  10. davidmigloz commented on Aug 18, 2025

    @davidmigloz
    Contributor

    @davidmigloz could you please share the exact steps to replicate the problem on our end?

    1. Create a new Flutter project.
    2. Edit the Xcode scheme file at ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme.
    3. Inside that file, find the LaunchAction and TestAction sections and change the selectedLauncherIdentifier value to "Xcode.IDEFoundation.Launcher.PosixSpawn".
    4. Run the app using flutter run. The build will fail with the Failed to find correct customLLDBInitFile error.

    Root cause

    The problem is in the _migrateScheme function within the lldb_init_migration.dart script.

    // ... inside _migrateScheme function
    final String newScheme = schemeContent.replaceAll(
      'selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"',
      '''
    selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
          customLLDBInitFile = "$_initPath"''',
    );
    // ...

    This code uses a hardcoded string replacement (replaceAll). It fails if the selectedLauncherIdentifier has 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, and customLLDBInitFile) 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.

  11. tirth-patel-nc commented on Aug 21, 2025

    @tirth-patel-nc
    Member

    @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
  12. davidmigloz commented on Aug 21, 2025

    @davidmigloz
    Contributor

    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.xcscheme file already contains the customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit" line from the very beginning.

    Image

    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.xcscheme file must:

    1. Not contain the customLLDBInitFile line.
    2. Have the selectedLauncherIdentifier set to "Xcode.IDEFoundation.Launcher.PosixSpawn".
  13. tirth-patel-nc commented on Aug 22, 2025

    @tirth-patel-nc
    Member

    @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.

    Launching lib/main.dart on iPhone 16 in debug mode...
    An error occurred when adding LLDB Init File:
    Exception: Failed to find correct customLLDBInitFile in LaunchAction for the Scheme in /Users/tirthpatel/au22/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme.
    Xcode build done.                                           14.0s
    Connecting to VM Service at ws://127.0.0.1:53489/bFQ1K0A5zTE=/ws
    Connected to the VM Service.
  14. davidmigloz commented on Aug 22, 2025

    @davidmigloz
    Contributor

    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.

  15. 28 remaining items

  16. self-assigned this
    on Aug 25, 2025
  17. davidmigloz commented on Aug 25, 2025

    @davidmigloz
    Contributor

    Thanks for the follow-up.

    It doesn't replicate on 3.29.3.

    That makes sense. The migration script that causes this issue was introduced in Flutter 3.32.0.

    Note: customLLDBInitFile ... line is already included during project creation. Issue occurs only and only when you remove it & replace selectedLauncherIdentifier.

    While new projects are created with the correct template, my project is over 5 years old. I don't recall ever changing the selectedLauncherIdentifier manually, 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.PosixSpawn value has been used:

    So, while the reproduction steps require modifying a new project, they represent the real-world state of older Flutter projects.

  18. added
    triaged-iosTriaged by iOS platform team
    P1High-priority issues at the top of the work list
    on Aug 28, 2025
  19. added
    r: fixedIssue is closed as already fixed in a newer version
    on Sep 5, 2025
  20. added a commit that references this issue on Sep 5, 2025
  21. github-actions commented on Sep 19, 2025

    @github-actions

    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 -v and a minimal reproduction of the issue.

  22. locked as resolved and limited conversation to collaborators on Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listfound in release: 3.32Found to occur in 3.32found in release: 3.35Found to occur in 3.35found in release: 3.36Found to occur in 3.36has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions