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.

Replies

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.