Xcode 13.3 freezes with SwiftPM at stage "Packages. Finishing..."

Does anyone know what Xcode does within the "Packages. Finishing..." stage and what could be done to debug it? We have quite a big packages tree that is resolved in ~200 seconds, but afterward, it proceed to this stage and Xcode freezes for 10-15 minutes, sometimes longer. I got spindump for this, and it has references to Playground, also on a disk there is a folder in DerivedData Build/Intermediates.noindex/Plagrounds changes size non-stop and grows to some very big numbers. We do not have Playgrounds. What could it be and what are possible ways to analyze and resolve the issue?

I did open radar, as well as wrote to Apple dev support without any answer so far.

5 Likes

Yes, there’s currently a bug in Xcode’s package handling that produces a hang when packages have playgrounds in their repo. You can either go back to 13.2.1 or go through your packages and delete the playgrounds. May want to go one repo at a time to see if you can narrow it down to just one.

5 Likes

This is amazing. Thank you so much, at least I have now a way forward, so I can start the hunt for the playgrounds.

Do you have a bug number handy, as I'd like to to follow up on that? Thanks!

1 Like

FB9964493
Is it now possible to follow radars if you know an id?

1 Like

Just to add to this post, we had a even worse problem:
Xcode wouldn't work with any Xcode 13 versions, so we where in a hurry to find a solution or we wouldn't be able to release any new versions from April 25 (last date that would accept Xcode 12 builds).
Luckily we found this post and its solution worked (after making several forks to remove .playgrounds from dependencies), so thank you @Jon_Shier. :smile:

Before finding the solution we also opened a Feedback (FB9977627) and eventually a DTS. We are still in touch with developer support through the DTS and they are now aware of the issue, hopefully it will lead to a solution soon enough. :pray:

2 Likes

@Robuske
Have you made any progress with Apple? I'm seeing that this behavior continues to exist in Xcode 14.1.0.

I can replicate this consistently with the following steps:

  • Open your project and let SPM dependencies resolve
  • Close, then reopen your project
    • Notice that SPM resolution lingers on Packages | Finishing...
  • navigate to ~/Library/Developer/Xcode/DerivedData/YourApp-/SourcePackages/checkouts
  • Delete any files in this directory + subdirectories that end in .playground
  • Reopen your project
    • Notice that SPM resolution does not linger on Packages | Finishing...

As a suggestion, if you're encountering that removing a particular playground file solves your issue, it can be worth adding that file deletion as a post checkout git hook, to ensure it regularly remains deleted whenever you may need to delete and regenerated derived data.
Specifically for me, it was a SQLite.playground file that had to be deleted from our dependency on this library.

This is still an issue in Xcode 15.4.

Wow, I just stumbled upon this thread.. thank you! This has been bugging me so much ever since we started to modularize our app with SPM.
Making this simple change now cut the time until Xcode becomes usable for me after launching it from ~55 seconds to ~12 seconds!

And this is considering we had just two playgrounds in there: one from SQLite.swift, and one from Promises.

Here's the command I used, and also added to our project's Makefile:

find ~/Library/Developer/Xcode/DerivedData/OurProject-*/SourcePackages/checkouts -type d -name "*.playground" -exec rm -rf {} +
1 Like