Repository navigation
Description
Steps to reproduce
- In an add-to-app Flutter module, run
flutter build swift-package(SwiftPM integration feature flag enabled). - Add the generated local package
build/ios/SwiftPackages/FlutterNativeIntegrationto a native iOS Xcode project (in my case via XcodeGenproject.yml, but plain Xcode package references hit the same path). - 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
FlutterNativeIntegrationumbrella package alone is enough to trigger the crash. - Narrowing further, the inner generated package
FlutterNativeIntegration/FlutterNativeToolsis the trigger. - Inside
FlutterNativeTools/Package.swift, the single.pluginproduct 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
mbcorona commentedon Sep 21, 2026
HI @AarifChan , thanks for the report.
Confirmed the plugin product is still emitted on main:
flutter/packages/flutter_tools/lib/src/commands/build_swift_package.dart
Lines 2013 to 2015 in 19946f9
Routing to the team tool for further investigation.
okorohelijah commentedon Sep 23, 2026
What this is:
flutter build swift-packagegenerates aFlutterNativeToolsPackage.swiftwith a single.pluginproduct (FlutterBuildModePlugin) listing three plugin targets (Switch to Debug/Profile/Release Mode). That manifest is valid per Apple'sPackageDescriptionAPI, but hits an upstream SwiftPM PIF builder assertion that assumes every.pluginproduct hascount == 1plugin target.What I verified:
_pluginToolatc3edad87emits the 3-target.pluginproduct unconditionally (introduced in Add integration scripts and tools for SwiftPM add to app #184204, in 3.44.0 through 3.47.x and master):flutter/packages/flutter_tools/lib/src/commands/build_swift_package.dart
Lines 2013 to 2019 in c3edad8
Product.plugin(name:targets:)explicitly accepts multiple targets (targets: [String]) and documents that a product is required to expose plugins to client packages: https://developer.apple.com/documentation/packagedescription/product/plugin(name:targets:)swift-package-manager(PackagePIFProjectBuilder+Products.swiftmakePluginProductat1263a5f) checksif let pluginTarget = pluginProduct.pluginModules!.only(Collection.onlyisnilwhencount != 1) and callsassertionFailure("This should never be reached since there is always exactly one plugin target in a product by definition"): https://github.com/swiftlang/swift-package-manager/blob/1263a5f603ac135ea00d1c74a35fa5144cd2b46a/Sources/SwiftBuildSupport/PackagePIFProjectBuilder%2BProducts.swift#L1097-L1111IDEEnableNewPackagePIFBuilder("will become the default in a future release"): https://developer.apple.com/documentation/xcode-release-notes/xcode-26-release-notesWhat 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.pluginproduct match the crash signature, but I could not run Xcode 27.0.To move this forward: @mbcorona @AarifChan - does splitting
FlutterBuildModePlugininto three single-target.pluginproducts (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.vashworth commentedon Sep 29, 2026
Note: In order to reproduce, the
NewPackagePIFBuildermust be enabled:vashworth commentedon Sep 29, 2026
Filed FB24993063
Split SwiftPM plugin into multiple products (flutter#193521)
github-actions commentedon Oct 28, 2026
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.Split SwiftPM plugin into multiple products (flutter#193521)