'Xcode 13.3 Build Failed because of Cycle in Dependencies between targets libsignal-protocol-swift

After updating to Xcode 13.3 facing Build failed issues with libsignal-protocol-swift library.

This is happening while building second time while after cleaning and building for first time it is working fine. Also, Xcode 13.2.1 has no such errors.

Xcode Error as below :

Cycle inside libsignal-protocol-swift iOS; building could produce unreliable results. This usually can be resolved by moving the target's Headers build phase before Compile Sources.

Cycle details:
→ Target 'libsignal-protocol-swift iOS' has link command with output '/Users/ankitkhanna/Library/Developer/Xcode/DerivedData/BlueSecures-brawgzawheasvqbvhxxglfnlvdlw/Build/Products/Debug-iphoneos/SignalProtocol.framework/SignalProtocol'
○ Target 'libsignal-protocol-swift iOS' has compile command for Swift source files
○ Target 'libsignal-protocol-swift iOS' has copy command from '/Users/ankitkhanna/Documents/Project-Files/Desk-Factors-Project-Files/BlueChats-IOS-master/libsignal-protocol-swift-master/libsignal-protocol-swift/SignalProtocol.h' to '/Users/ankitkhanna/Library/Developer/Xcode/DerivedData/BlueSecures-brawgzawheasvqbvhxxglfnlvdlw/Build/Products/Debug-iphoneos/SignalProtocol.framework/Headers/SignalProtocol.h'


Solution 1:[1]

After struggling for sometime the solution was actually the same as mentioned in Xcode suggestions.

i.e. to Move the Headers in project Target -> Build Phases on top Compiled sources.

Drag and move Headers above Compile Sources fixed the error. Please see the image for reference.

enter image description here

enter image description here

Solution 2:[2]

I've faced the same issue after updating to Xcode 13.3; however in my case I didn't have Headers in Build Phases.

I've followed these steps to solve it:

  • Precondition: Xcode must be closed.
  • Delete Derived Data folder. You can access to that folder by opening this path from the Terminal (and replacing "your_username" by your actual username):

open /Users/your_username/Library/Developer/Xcode/DerivedData

  • In the Terminal, type the following command:

defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ankit Khanna
Solution 2