XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

Error "The workspace contains multiple references with the same GUID"

Open niklas-tag24 opened this issue 7 months ago • 8 comments

Everytime I execute xcodegen in my project, and then build the iOS app, I receive the same error

Build service could not create build operation: unable to load transferred PIF: The workspace contains multiple references with the same GUID 'PACKAGE:1YPFJ9C2MTIAXFLQNBJR1G6455KB9KR79::MAINGROUP'

I always have to close and re-open Xcode in this case, which really hinders programming.

I don't really understand how this can even happen. xcodegen basically only rewrites the pbxproj-stuff without using internal xcode APIs like xcodebuild, right? So why does the build operation complain, does someone have an idea?

I also analysed the pbxproj-changes that xcodegen applies. The weird thing is, even if there are no changes at all (because I've executed xcodegen beforehand) then I also get the same error as before.

So if xcodegen doesn't use Xcode API (I suppose), and there are no changes to the .pbxproj-Stuff, what could xcode even complain about?

niklas-tag24 avatar Jul 02 '25 08:07 niklas-tag24

Do you have duplicate packages referenced in your project spec?

yonaskolb avatar Jul 02 '25 16:07 yonaskolb

Only through transitive dependencies. We have an SPM-Package A that includes B, and we also have to include B ourselves in the project spec again to use it in the main app. And sorry for the late response, I haven't received any notification.

niklas-tag24 avatar Jul 09 '25 08:07 niklas-tag24

@yonaskolb

niklas-tag24 avatar Jul 11 '25 12:07 niklas-tag24

I've create a minimal "working" example here https://github.com/niklas-tag24/ExampleXcodegenIssue

niklas-tag24 avatar Jul 16 '25 07:07 niklas-tag24

@yonaskolb Have you already found the time looking at the minimal example I've provided?

niklas-tag24 avatar Jul 29 '25 08:07 niklas-tag24

Hi @niklas-tag24, I tried your project and could reproduce that generating while the project is open leads to the error Missing package product 'MyPackage'. I believe it's due to a long standing bug in Xcode https://forums.swift.org/t/missing-package-product-error-for-all-local-swift-packages-when-switching-git-branches/38041/54. Sorry I can't offer more help

yonaskolb avatar Jul 30 '25 00:07 yonaskolb

Xcode just doesn't like when it's project changes out from underneath it, even in branch switching scenarios

yonaskolb avatar Jul 30 '25 00:07 yonaskolb

Thank you for your reply. :) So it seems that the only "fix" would be to remove local packages from our app, right?

niklas-tag24 avatar Jul 30 '25 07:07 niklas-tag24