swift-package-manager: Internal inconsistency error (didStartTask)
Description
When Package.swift contains a plugin that generates code using `.prebuildCommand’. this leads to a build error:
Internal inconsistency error (didStartTask): targetID (174) not found in _activeTargets.
Internal inconsistency error (didEndTask): '12' missing from _activeTasks.
For example SwiftGenPlugin has this issue https://github.com/SwiftGen/SwiftGenPlugin/issues/15 Or others plugin like Sourcery.
To get rid of this error, you need to call the build cleanup and rebuild the project.
There are also other discussions of a similar problem:
Expected behavior
Expected Behavior: The build process should complete successfully without any internal inconsistency errors.
Actual behavior
Actual Behavior: Xcode displays the internal inconsistency error message and subsequent builds fail to produce the expected result, launching stale products instead.
Steps to reproduce
- Install and configure SwiftGenPlugin in Xcode.
- Make changes to the build plan, such as adding a file, or start a build during Xcode’s indexing stage.
- Observe the build error message:
Internal inconsistency error (didStartTask): targetID (174) not found in _activeTargets.
Internal inconsistency error (didEndTask): '12' missing from _activeTasks.
Swift Package Manager version/commit hash
5.7-5.9(latest)
Swift & OS version (output of swift --version ; uname -a)
Xcode version: 14.3.1 swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100) Target: arm64-apple-macosx13.0 Darwin barredewe 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 arm64
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 12
- Comments: 17 (5 by maintainers)
This definitely looks like a bug around XCBuild, and it’s still an issue in Xcode 15.0 RC. The build error strings originate from
Xcode.app/Contents/PlugIns/XCBuildSupportCore.ideplugin/Contents/MacOS/XCBuildSupportCore, but it’s near-impossible for us to debug it further, because XCBuildSupportCore is closed source.We’re hit by this issue almost daily. Having to first realise that you’d been debugging an old build all along because the build silently failed, and then clean all and rebuild… Can’t say it’s a great developer experience.
Xcode 15.1 beta reports the inconsistency as an error now which is a step in the right direction 👍
In Xcode 16 Beta it seems to have been fixed:
Still a bug in Xcode 15.1. This is a crippling problem for anyone using SPM plugins from Xcode.
Cleaning the build folder often works around this. Less drastically, simply clearing the error (
Product/Clear All Issues) and building again sometimes resolves the problem temporarily.FTR, still a major problem in Xcode 15.4 released yesterday.
It got worse for me as well in 15.3. Before it would happen every other recompile, but now it happens every time for me.
It has also gotten much much worse with Xcode 15.3. The only “improvement” is that the message now appends: “Build again to continue”. Thanks, I will. 🙄
Can someone from Apple (e.g., @abertelrud or @neonichu) please escalate this internally? Feedback reports are just ignored.
@sebj Yes here:
FB13368618I’ve also found that closing and re-opening Xcode is the quickest way (faster than clean, slower than clear all issues) to (usually) resolve this issue.
This looks like output from XCBuild, so this should be Xcode-specific. cc @abertelrud