When running some async unit tests, we sometimes see some errors spit out that don't fail our build. Examples look like:
Internal inconsistency error (didStartTask): targetID (174) not found in _activeTargets.
Internal inconsistency error (didEndTask): '12' missing from _activeTasks.
I'm not sure if this is a Swift runtime error. The "internal inconsistency" seems to hint at a Swift-level bug rather than a mistake in my code, but I'm not certain and don't want to write it off too quickly. It started showing up when I added unit tests that spawn their own Tasks and then use
waitForExpectations to wait for them to complete. Inside of a unit test, do we need to do anything special to manage Tasks that might still be running when the test fails? Do we need to make sure to cancel them all? Is it safe to cancel ones that completed successfully?
@cocoaphony have you found any workaround on this?
Have the same issue, but during running app mode in debug on simulator.
Workaround for my case:
Clean project -> Build -> Run == ALL is OK but time to waste ;(
We encountered this issue despite not using Swift concurrency. We found that disabling test parallelization for the affected test targets resolved the issue.
I have the same error but it affects my main target and not my test target, so I would assume that it does not have anything to do with it.
I'm also seeing these errors with the main target, and the build is incorrectly marked as successful. I think these issues appeared after adding local SPM packages. I'm using Xcode 14.2.
This has also been my case -- I have a local Swift package inside an Xcode project and changes to its modules causes builds to be incorrectly marked as successful with
Internal inconsistency error (didStartTask): targetID (...) not found in _activeTargets, making it seem like an incremental build occurred. In reality, the build that gets run is stale and the only fix I have found is to do a clean build.
One workaround that may be faster that a completely clean build, I have found, was to go to the command line and build your target there. This ought to unjam the
didStartTask error. Once that build completes, I can go back to Xcode and keep working/building. I haven't tried this for all target types, though.
is your swift package using a
also experiencing this in Xcode 14.3.0
This happens all the time with no rhyme or reason and the culprit is simply Xcode. It is really annoying when you discover you wasted a bunch of time testing something other than the code you are looking at. Once I have noticed and grumbled, I get it back on track by simply quitting and re‐launching Xcode. The trigger seems to be making a change to the build plan (such as adding a file) or starting a build while Xcode is at an unlucky stage of indexing so that it scrambles Xcode’s build cache. Then Xcode’s next build gets tangled and all subsequent builds fail to fail, so that nothing is actually built and a stale product is silently launched instead. That continues indefinitely until something else convinces Xcode to reinitialize—a re‐launch, @qasim’s [Edit: Oops, actually @fibrechannelscsi’s] command line build, or if you are lucky, building for a different target platform, updating a dependency, or some similar action sometimes fortuitously voids just the right bit of the cache in a particular instance.
Yes, I'm using SwiftGen in a few targets, and experiencing this issue still in 14.3.0 as well
We're experiencing this as well and it started around when we added Rswift as a Build Tool Plugin. But we have not confirmed this by removing Rswift, yet.
We were in a similar situation - using a build plugin to generate a single file. Issues disappeared when we replaced that plugin with a symlink to the file instead.
Not suggesting that as a solution, just adding a data point.
Same issue. We also have a Build Tool Plugin which runs Swiftgen. Unfortunately it's difficult to remove it due to active development, so also can't confirm that the source of the issue is the build plugin :(
I have the same errors in Xcode 14.3.1. When errors appear application runs but without last code changes. To fix it I restart Xcode.
We have the same issue too. I’m considering removing the plug-in (swiftgen) and running it by hand unless on ci. Cleaning fix the issue but when the project is large this is randomly killing productivity. It is particularly painful when working with SwiftUI and previews as we are constantly starting incremental builds.
Myself and my team also experience this issue intermittently. We're also using SwiftGen with Swift Build Plugins. Does anyone know if Xcode 15 resolves this issue or if anyone at Apple is looking into it? (cc. @NeoNacho)
I'm still experiencing this issue in Xcode 15 beta 5.
SwiftGen was causing the errors for us too. We ended up removing the plugin and running SwiftGen as a build pre-action (
Xcode > Product > Scheme > Edit Scheme > Build > Pre-actions > New Run Script Action).
This is still a problem in Xcode 15.0 RC.
The origin of the error appears to be in an internal plugin of Xcode named XCBuildSupportCore. There is a GitHub issue in the SwiftPM repository: Internal inconsistency error (didStartTask) · Issue #6705 · apple/swift-package-manager · GitHub
I think the correct way to take this forward is via https://feedbackassistant.apple.com.