Skip to content

[swift-package] Generated FlutterNativeTools package crashes Xcode 27.0 during package graph resolution (.plugin product triggers SwiftPM PIF builder assertion) #193093

Closed

Description

@AarifChan

Steps to reproduce

  1. In an add-to-app Flutter module, run flutter build swift-package (SwiftPM integration feature flag enabled).
  2. Add the generated local package build/ios/SwiftPackages/FlutterNativeIntegration to a native iOS Xcode project (in my case via XcodeGen project.yml, but plain Xcode package references hit the same path).
  3. Open the project in Xcode 27.0 (or run xcodebuild -resolvePackageDependencies).

Expected results

Xcode opens the project and resolves the package graph.

Actual results

Xcode crashes on the main thread while SwiftPM builds the PIF (Project Interchange Format) for the package graph:

Exception Type:    EXC_BREAKPOINT (SIGTRAP)
Exception Codes:   0x0000000000000001

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   SwiftPM                SPMPIFBuilder.ModuleOrProduct.init(from:package:) + 2140
1   SwiftPM                SPMPIFBuilder.build() + 300
2   IDESwiftPackageCore    NewPackagePIFWithBlueprintsBuilder.build() + 176
3   IDESwiftPackageCore    protocol witness for PackagePIFWithBlueprintsBuilder.build() ...
4   IDESwiftPackageCore    IDESwiftPackage.update(from:graphHasErrors:delegate:) + 5212
5   IDESwiftPackageCore    IDESPMWorkspaceDelegate.dependencyPackagesDidUpdate(...)
...
18  SwiftPM                SPMWorkspace.packageGraphActionFinished(_:)

The crash is a Swift assertion failure (SIGTRAP) inside Xcode's SwiftPM PIF builder, so the project cannot be opened at all.

Root cause (bisected)

I bisected by generating minimal Xcode projects with xcodegen and resolving packages with xcodebuild -resolvePackageDependencies:

  • The generated FlutterNativeIntegration umbrella package alone is enough to trigger the crash.
  • Narrowing further, the inner generated package FlutterNativeIntegration/FlutterNativeTools is the trigger.
  • Inside FlutterNativeTools/Package.swift, the single .plugin product declaration is the only line that triggers the assertion:
products: [
    .plugin(name: "FlutterBuildModePlugin", targets: ["Switch to Debug Mode", "Switch to Profile Mode", "Switch to Release Mode"]), // <-- removing this line fixes the crash
    .executable(name: "flutter-assemble-tool", targets: ["FlutterAssembleTool"]),
    .executable(name: "flutter-prebuild-tool", targets: ["FlutterPrebuildTool"])
],

Notably, the command plugin targets themselves (.plugin(name: "Switch to Debug Mode", capability: .command(...)), including target names containing spaces) do not cause the crash — only exposing them as a plugin product does. Executable products are fine too.

This product is generated in packages/flutter_tools/lib/src/commands/build_swift_package.dart (_pluginTool, SwiftPackageProduct.plugin(name: 'FlutterBuildModePlugin', ...)).

Workaround

Delete the .plugin(name: "FlutterBuildModePlugin", ...) product line from the generated FlutterNativeTools/Package.swift. The package then resolves and the project opens normally. This product only backs the Xcode menu commands for switching the Flutter build mode; the build itself only uses the flutter-assemble-tool / flutter-prebuild-tool executable products, so removing it does not affect building.

This also looks like an Xcode 27 SwiftPM bug (an assertion in SPMPIFBuilder.ModuleOrProduct.init should never crash on a valid manifest), which I will report to Apple separately — but Flutter could avoid shipping the plugin product (or gate it) so projects keep working on Xcode 27.

Logs

Full Xcode crash report (truncated to crashed thread)
Process:             Xcode
Version:             27.0 (25183.107.5)
OS Version:          macOS 27.0 (26A428)
Exception Type:      EXC_BREAKPOINT (SIGTRAP)
Termination Reason:  Namespace SIGNAL, Code 5, Trace/BPT trap: 5

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   SwiftPM              SPMPIFBuilder.ModuleOrProduct.init(from:package:) + 2140
1   SwiftPM              SPMPIFBuilder.build() + 300
2   IDESwiftPackageCore  NewPackagePIFWithBlueprintsBuilder.build() + 176
3   IDESwiftPackageCore  protocol witness for PackagePIFWithBlueprintsBuilder.build() in conformance NewPackagePIFWithBlueprintsBuilder + 20
4   IDESwiftPackageCore  IDESwiftPackage.update(from:graphHasErrors:delegate:) + 5212
5   IDESwiftPackageCore  specialized IDESPMWorkspaceDelegate.dependencyPackagesDidUpdate(packages:graphHasErrors:revalidatedFilePathCaches:modelGraphSynchronizerToken:) + 1232
6   IDESwiftPackageCore  closure #2 in IDESPMWorkspaceDelegate.packageGraphDidFinishAction(_:duration:result:) + 1492
...
16  IDESwiftPackageCore  IDESPMWorkspaceDelegate.packageGraphDidFinishAction(_:duration:result:) + 176
18  SwiftPM              SPMWorkspace.packageGraphActionFinished(_:) + 1
19  SwiftPM              closure #2 in closure #3 in SPMWorkspace.processPackageGraphActionsInBackgroundIfNeeded(canProcessPackageGraphActions:) + 1
23  libswift_Concurrency.dylib  completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1

Flutter Doctor output

Doctor output
[!] Flutter (Channel stable, 3.47.1, on macOS 27.0 26A428 darwin-arm64, locale zh-Hans-CN)
    • Flutter version 3.47.1 on channel stable
    • Framework revision 6655482ec0 (5 weeks ago), 2026-08-19 10:07:23 -0700
    • Engine revision 5d53178869
    • Dart version 3.13.1
    • Feature flags: ... enable-swift-package-manager ...

[✓] Xcode - develop for iOS and macOS (Xcode 27.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 27A266a
    • CocoaPods version 1.16.2

Activity

  1. added
    platform-iosiOS applications specifically
    toolAffects the "flutter" command-line tool. See also t: labels.
    a: existing-appsIntegration with existing apps via the add-to-app flow
    team-iosOwned by iOS platform team
    on Sep 21, 2026
  2. mbcorona commented on Sep 21, 2026

    @mbcorona
    Member

    HI @AarifChan , thanks for the report.

    Confirmed the plugin product is still emitted on main:

    ({SwiftPackageProduct product, List<SwiftPackageTarget> targets}) get _pluginTool {
    final product = SwiftPackageProduct.plugin(
    name: 'FlutterBuildModePlugin',

    Routing to the team tool for further investigation.

  3. okorohelijah commented on Sep 23, 2026

    @okorohelijah
    Contributor

    What this is: flutter build swift-package generates a FlutterNativeTools Package.swift with a single .plugin product (FlutterBuildModePlugin) listing three plugin targets (Switch to Debug/Profile/Release Mode). That manifest is valid per Apple's PackageDescription API, but hits an upstream SwiftPM PIF builder assertion that assumes every .plugin product has count == 1 plugin target.

    What I verified:

    What I could not verify: Running Xcode 27.0 on macOS 27.0 to confirm the crash or test the fix (Linux host).

    Confidence: Medium - upstream makePluginProduct (pluginModules!.only) and Flutter's 3-target .plugin product match the crash signature, but I could not run Xcode 27.0.

    To move this forward: @mbcorona @AarifChan - does splitting FlutterBuildModePlugin into three single-target .plugin products (one per mode) resolve the Xcode 27 crash without dropping the "Switch to ... Mode" commands from client projects?

    Pre-triage by Elijah's_triage_agent — verify before acting on it.

  4. added
    P1High-priority issues at the top of the work list
    triaged-iosTriaged by iOS platform team
    on Sep 24, 2026
  5. vashworth commented on Sep 29, 2026

    @vashworth
    Contributor

    Note: In order to reproduce, the NewPackagePIFBuilder must be enabled:

    defaults write com.apple.dt.Xcode IDEEnableNewPackagePIFBuilder -bool YES
    
  6. vashworth commented on Sep 29, 2026

    @vashworth
    Contributor

    Filed FB24993063

  7. github-actions commented on Oct 28, 2026

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

  8. locked as resolved and limited conversation to collaborators on Oct 28, 2026
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 lista: existing-appsIntegration with existing apps via the add-to-app flowfyi-toolFor the attention of Flutter Tool teamplatform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-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