Multiple commands produce - Command ProcessXCFramework

My current iOS 13+ (xcode 12.5) simplified project setup has some nested dependencies as follows:

Alamofire.xcframework -- is linked into -> Internal-Framework-A
Alamofire.xcframework -- is linked into -> Internal-Framework-B


Internal-Framework-A -- is linked into -> AppTarget (actual application target)
Internal-Framework-B -- is linked into -> AppTarget

Because Alamofire.xcframework is being linked into multiple internal frameworks, it will be linked without actual embedding. This means that AppTarget will need to link and embed Alamofire.xcframework so that the internal frameworks can dynamically link it at runtime.

Internal frameworks compile correctly with this setup but AppTarget doesn't compile and it's trowing the follow error: 
Multiple commands produce ... Command: ProcessXCFramework and the reason for that being:
  • on compile time AppTarget compiles Internal-Framework-A that triggers the ProcessXCFramework for Alamofire.xcframework but because AppTarget also has Alamofire.xcframework as dependency it will also run the ProcessXCFramework command, so we will have 2 commands for the same file.

I'm curious to know if there is something that I'm missing. It would look like there should be a flag for xcode to process the same framework once.

The weird behaviour happened to me as well. I had the following setup:

A.xcframework linked to --> Internal-Framework-A (not Embedded);

Internal-Framework-A linked into --> the AppTarget;

A.xcframework linked and Embedded into the AppTarget so it's available to the Internal-Framework-A.;

What worked for me was setting A.xcframework as Optional in Build Phases > Link Binary with Libraries in the Internal-Framework-A project. More information about what that means can be found at: https://stackoverflow.com/questions/33038137/xcode-and-optional-frameworks . Maybe this scenario doesn't make that much sense in your situation.

Hi. Did you find a way to solve this? Thanks

I have a similar setup in which I don't understand why the conflict would take a place. I will first show the setup, and then share why I think there should not be such a conflict

Linkage scheme is basic "nested dependency" case, where the dependency is static xcframework

MyApp -> FirebaseAnalytics.xcframework (Static)
MyApp -> MyFramework (Dynamic) -> FirebaseAnalytics.xcframework (static)

I use Workspace to build MyFramework as a dependency

Workspace (named HRS)
* MyApp project
** MyApp target (links MyFramework.framework from Workspace -> MyFramework project)
* MyFramework project
** MyFramework target

When in Workspace I build MyApp, it first gives me warnings, such as

duplicate output file '/Users/oleksiinezhyborets/Library/Developer/Xcode/DerivedData/HRS-etdtlgdbraymsbdmilzwmgmwkjgs/Build/Products/Debug-iphonesimulator/FirebaseAnalytics.framework' on task: ProcessXCFramework /Users/oleksiinezhyborets/Projects/tv_mobile_ios 2/MyFramework/FirebaseFrameworks/Analytics/FirebaseAnalytics.xcframework /Users/oleksiinezhyborets/Library/Developer/Xcode/DerivedData/HRS-etdtlgdbraymsbdmilzwmgmwkjgs/Build/Products/Debug-iphonesimulator/FirebaseAnalytics.framework ios simulator

And then error:

Multiple commands produce '/Users/oleksiinezhyborets/Library/Developer/Xcode/DerivedData/HRS-etdtlgdbraymsbdmilzwmgmwkjgs/Build/Products/Debug-iphonesimulator/FirebaseAnalytics.framework'

Command: ProcessXCFramework /Users/oleksiinezhyborets/Projects/tv_mobile_ios 2/MyApp/FirebaseFrameworks/FirebaseAnalytics/FirebaseAnalytics.xcframework /Users/oleksiinezhyborets/Library/Developer/Xcode/DerivedData/HRS-etdtlgdbraymsbdmilzwmgmwkjgs/Build/Products/Debug-iphonesimulator/FirebaseAnalytics.framework ios simulator

Command: ProcessXCFramework /Users/oleksiinezhyborets/Projects/tv_mobile_ios 2/MyFramework/FirebaseFrameworks/Analytics/FirebaseAnalytics.xcframework /Users/oleksiinezhyborets/Library/Developer/Xcode/DerivedData/HRS-etdtlgdbraymsbdmilzwmgmwkjgs/Build/Products/Debug-iphonesimulator/FirebaseAnalytics.framework ios simulator

So, ok, I understand that Xcode and New Build System doesn't support multiple same output files. But I think it should work in such a setup because of the combination of factors:

  1. Firebase is linked statically to MyFramework, thus, at the end of MyFramework build there wouldn't be FirebaseAnalytics.xcframework in output destination. They are probably needed temporarily while build happens.
  2. Because MyApp depend on MyFramework, dependencies in the setup build serially one after another.

My thought is, there is some kind of checker in Xcode that checks output files at start of a build, and if there are duplicates, it gives error right away. In this case it checks outputs of ProcessXCFramework. But in this case it's restrictive without a reason. In this case, we will have 2 steps: first MyFramework would process its Firebase xcframeworks, build the framework, and remove all the temporary xcframeworks. And then the app target would also process same xcframeworks at the same place. But as MyFramework is already build into a single binary and all temporary files are removed, there wouldn't be a conflict.

Why it's a problem?

It prevents from automatically rebuilding the dependent framework, and also from debugging the framework with breakpoints. Access to both these features is pretty needed for a better development. I do understand that covering different cases in build system make it even more complex, but this case seems to be pretty basic, so if I'm right that it may be fixes, it may be good if it's fixed

Multiple commands produce - Command ProcessXCFramework
 
 
Q