Cycle inside ; building could produce unreliable results: Xcode Error

IosXcodeCompile TimeBuild System

Ios Problem Overview


I am trying to move to the new build system when compiling with Xcode 10. However, it gives the following error:

Cycle details:
→ Target 'project' : LinkStoryboards

Target 'project' has compile command with input '/Users/project/Commons/Components/ScreenshotSharing/ViewController/AppShare.storyboard'

Target 'project' : ValidateEmbeddedBinary /Users/project/Xcode/DerivedData/project-hgqvaddkhmzxfkaycbicisabeakv/Build/Products/Debug-iphoneos/project.app/PlugIns/stickers.appex

Target 'project' has process command with input '/Users/project/Resources/Info.plist'

Target 'project' has compile command with input '/Users/project/Commons/Components/ScreenshotSharing/ViewController/AppShare.storyboard'

Screenshot added

Even after removing the problem file, I get the same for another xib/storyboard. How can I solve this error without reverting to the legacy build system?

Ios Solutions


Solution 1 - Ios

For anybody having an issue with Xcode 10 build system, follow the following steps to fix it:

> 1. In Xcode, go to File->Project/Workspace settings. > 2. Change the build system to Legacy Build system.

It will resolve the build issue with the new Xcode.

If you want to work with the new build system, then you can find the troubleshooting help from this apple Xcode help page.

Solution 2 - Ios

I was having this issue with Cocoapods. The solution was to clean the build folder re-install all pods, and then rebuild the app. The issue resolved itself that way.

Solution 3 - Ios

In fact, you only need to pay attention to Xcode's prompt This usually can be resolved by moving the target's Headers build phase before Compile Sources, and then you can do it.

When I encountered this problem, Xcode prompts me:

:-1: Cycle inside XXXX; building could produce unreliable results. This usually can be resolved by moving the target's Headers build phase before Compile Sources.
Cycle details:
→ Target 'XXXX': LinkStoryboards
○ Target 'XXXX: Ditto Path/XXXX-Swift.h /Path/XXXX-Swift.h
○ Target 'XXXX has compile command for Swift source files
○ That command depends on command in Target 'XXXX: script phase “Run Script”

I only did one thing and solved the problem perfectly:

Select Target and then select Build Phase to move the Run Script to the front of Compile Sources.

Run, compiled successfully.

The principle is simple, just change the compilation order.

image 1

Xcode 10.2 & Swift 5

Solution 4 - Ios

I fixed my problem by moving the 'Copy Bundle Resources' Build Phase before all my 'Copy Files' & 'Link Binary with Libraries' Build Phases

Solution 5 - Ios

I was having this issue with Cocoapods and found a temporary workaround:

  1. Install latest version of cocoapods (1.5.3): sudo gem update cocoapods
  2. Delete you derived data: rm -rf ~/Library/Developer/Xcode/DerivedData/*
  3. pod install

Source here and I'm on Xcode 10 beta 4.

EDIT: now on Xcode 10.0 and still relevant.

Solution 6 - Ios

Xcode 10's new build system detects dependency cycles in your build and provides diagnostics to help you resolve them. Fixing these dependency cycles improves the reliability of your build, so that the correct products are produced consistently (cycles are a possible cause of needing to delete your derived data). It also improves your incremental build times, as cycles in the build cause something in your build graph to always be out-of-date on each build, making the build re-do work unnecessarily every time you build.

There is documentation on resolving some common types of dependency cycles in Xcode Help: https://help.apple.com/xcode/mac/current/#/dev621201fb0

That said, this cycle diagnostic looks a little odd. It sounds like you were able to resolve it by re-arranging your build phases, but I don't think the diagnostic really explained the problem. If you wouldn't mind, a bug report about improving this diagnostic for this particular case would be very much appreciated. You can file one at https://bugreport.apple.com. Please include all details about your project that you think might be relevant; a sample project that reproduces the issue is ideal, but if you can't attach that, the diagnostic and some idea of the project structure is still helpful.

Solution 7 - Ios

I had a similar issue with a mixed interaction between Swift, Objective-C and CoreData: in my project (written in Swift) I made use of Core Data's autogenerated Swift classes as well.

But at one point I needed an Objective C class with public properties (defined in its header counterpart) referring the the core data entities.

#import "ProjectName-Swift.h" // this is to import the swift entities into ObjC

@interface myObjCClass : NSObject

@property (nonatomic) MyCoreDataClass*myEntity;

@end

As soon as I changed the CoreData model, XCode tried to rebuild the classes and I got hung with the indicated cycle build error.

After an initial moment of despair, as I did not have any compile header phases in my project to change the order of, I found out that solution was quite simple:

In the myObjCClass.h I removed the shared Swift header import statement and changed it with a @class directive:

@class MyCoreDataClass; // tell the compiler I will import the class definition somewhere else

// the rest stays the same
@interface myObjCClass : NSObject

@property (nonatomic) MyCoreDataClass*myEntity;

@end

and I moved the #import "ProjectName-Swift.h" statement into the myObjCClass.m class definition file.

#import "myObjCClass.h"
#import "ProjectName-Swift.h"

@implementation myObjCClass

@end

And it builded no worries.

Solution 8 - Ios

I was finally able to resolve this by moving Embed App Extensions script in Build Phases of main Target to last position.

Solution 9 - Ios

My solution was simply to Clean Build Folder then re-build.

Solution 10 - Ios

In the target's Scheme, find the label Build, and ensure that Find Implicit Dependencies is not checked. These steps may work.

Solution 11 - Ios

I was facing the same issue: below was the error

> Cycle in dependencies between targets 'Pods-MyAppName' and 'RxCocoa'; > building could produce unreliable results. This usually can be > resolved by moving the target's Headers build phase before Compile > Sources. Cycle path: Pods-MyAppName → RxCocoa → Pods-MyAppName

I solved it using the below steps:

1). Go to target RxCocoa in Pods-MyAppName project

  1. Go to build phases

  2. Drag the Headers Phase and move it above the Complile Sources build phase.

This fixed my issue. Hope it helps!

Solution 12 - Ios

My issue had to do with a cyclical dependency between my swift bridging header and my objective c files.

In my objective c header files I had a #import "...-swift.h" file and then in a couple of my swift files I was including those files with said import and thus causing a cyclical dependency.

This is the StackOverflow that led me to find the solution:

https://stackoverflow.com/questions/31510901/objective-c-swift-interoperability-issue-due-to-circular-dependency

https://stackoverflow.com/questions/25670431/how-to-prevent-circular-reference-when-swift-bridging-header-imports-a-file-that

EDIT:

I wound up converting the above files to swift and this solved my issue.

Solution 13 - Ios

The best temporary fix I've found (until you resolve the root problem) is to make a simple change to the source code (even something as trivial as adding a new line) then trying again. I find that making even a whitespace change is enough to allow it to build again. However, this is definitely temporary as it will likely happen again after a few tries.

This is better than cleaning the build folder (which I found to also be temporary) since it's much quicker to make a whitespace change and rebuild, than to clean the build folder and rebuild (especially on larger projects).

Solution 14 - Ios

I have the same issue with Cocoapods.

Firstly, remove pods:

rm -rf ios/Pods

then install pods again:

cd ios && pod install && cd ..

Then run your app, it should works now.

Solution 15 - Ios

I've met similar issue when tried to archive my project on Xcode 10. Here's the detail text:

→ Target 'mytarget': CodeSign /path/to/mytarget.app

○ Target 'mytarget': SetGroup staff /path/to/mytarget.app

○ Target 'mytarget': SetMode u+w,go-w,a+rX /path/to/mytarget.app

○ Target 'mytarget': SetGroup staff /path/to/mytarget.app

Fixed it by setting $(USER) in mytarget -> Build Settings -> Deployment -> Install Owner

Solution 16 - Ios

It seems that you need to change the order of the build phases within your Pods targets. For me, moving Headers above the rest worked. You can automate this in your Podfile:

require 'xcodeproj'

post_install do |installer|
  installer.pods_project.targets.each do |target|
    headers_phase = target.build_phases.find { |p| p.kind_of?(Xcodeproj::Project::Object::PBXHeadersBuildPhase) }
    if headers_phase
      puts "#{target.name}: Moving Headers build phase to top"
      target.build_phases.insert(0, target.build_phases.delete_at(target.build_phases.index(headers_phase)))
    end
  end
end

Solution 17 - Ios

Same issue on Version 10.0 beta 3 (10L201y) and I wanted to have the New Build System.

Problem is had disabled Enable Modules (C and Objective-C)

in Build Settings -> Apple Clang - Language - Modules

After enabling it (set to YES) got rid of the Error.

Solution 18 - Ios

Core_Data

I had the same problem and error but mine happened when I "Created NSManagedObject Subclass" for my entity and I faced this error. So if you think your error is same as mine about Core Data what can probably help you (and helped me ) is to:

  • click on your Entity in you "xcdatamodel" file
  • go to your right bar click on Data Model Inspector
  • change "Module" to "Current Product Module"
  • and finally, change "Codegen" to "Manual/None"
  • clean and build

I think because in other scenarios Xcode creates a file automatically and when we create another one it causes a conflict.

Solution 19 - Ios

You might be able to fix this here:

File -> Workspace Settings -> Build System: New Build System

Workspace Settings

Solution 20 - Ios

Xcode 10.2.1/Unit Test Target. My unit test target is independent of host target to improve building time. Solve it by uncheck Find Implicit Dependencies in Scheme - Build options, As i specify all dependencies in Build Settings - Compile Sources.

Solution 21 - Ios

Xcode: 11.3.1 Target: XCUITest target

  1. Run command to clean build folder : rm -rf ~/Library/Developer/Xcode/DerivedData/*

  2. Change workspace settings: Select Legacy Build System

enter image description here

Solution 22 - Ios

I have tried things from this page but the only thing that has helped me was that I made a copy of the target and updated the name of the copy (removed the copy suffix), and deleted the old one, and did pod install afterwards.

Solution 23 - Ios

I faced this problem after updating Xcode to version 11.4. Downgrading to 11.2.1 fixed it.

Solution 24 - Ios

Had this problem for a while as well. Added the following block at the end of the podfile (this will also get rid of some warnings):

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.deployment_target = ios_version
    target.build_configurations.each do |config|
      config.build_settings['IOS_DEPLOYMENT_TARGET'] = 'iOS ' + ios_version
    end
  end
end

I also moved use_frameworks! to the root of the Podfile.

Solution 25 - Ios

In my case,

Removed all pods and reinstall resolved the error

Remove Pods directory in ios folder
pod install

Solution 26 - Ios

Only for Expo

  1. expo prebuild --clean
  2. cd ios
  3. pod install
  4. yarn ios

Solution 27 - Ios

In the project pane on the LHS, for your build products, don't select them in the list for Target membership in the RHS pane.

Solution 28 - Ios

Following two options worked for me: File->Project/Workspace settings.

1, Change the build system to "Legacy Build system" in File->Project Settings

2, Edit Scheme and Select "Parallelize Build" option under Build section.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSahil KapoorView Question on Stackoverflow
Solution 1 - IosAkshay SunderwaniView Answer on Stackoverflow
Solution 2 - IosJALView Answer on Stackoverflow
Solution 3 - IosShevaKuilinView Answer on Stackoverflow
Solution 4 - IosgypsyDevView Answer on Stackoverflow
Solution 5 - IosgabuchanView Answer on Stackoverflow
Solution 6 - IosRick BallardView Answer on Stackoverflow
Solution 7 - IosLookajiView Answer on Stackoverflow
Solution 8 - IosSahil KapoorView Answer on Stackoverflow
Solution 9 - IosonemoreanimalView Answer on Stackoverflow
Solution 10 - IosNh XuView Answer on Stackoverflow
Solution 11 - IosNishu_PriyaView Answer on Stackoverflow
Solution 12 - IosConstantineView Answer on Stackoverflow
Solution 13 - IosSensefulView Answer on Stackoverflow
Solution 14 - IoskarolkarpView Answer on Stackoverflow
Solution 15 - IoslikecatfoodView Answer on Stackoverflow
Solution 16 - IosbcherryView Answer on Stackoverflow
Solution 17 - IosvauxhallView Answer on Stackoverflow
Solution 18 - IosAlireza ajView Answer on Stackoverflow
Solution 19 - IosSepCodeView Answer on Stackoverflow
Solution 20 - IosJimmyView Answer on Stackoverflow
Solution 21 - IosKshama SinghView Answer on Stackoverflow
Solution 22 - IosVladimír SlavíkView Answer on Stackoverflow
Solution 23 - IosDeepseeyView Answer on Stackoverflow
Solution 24 - IosLucas van DongenView Answer on Stackoverflow
Solution 25 - IosHarshan MorawakaView Answer on Stackoverflow
Solution 26 - IosDaniel DanieleckiView Answer on Stackoverflow
Solution 27 - Iosuser10658782View Answer on Stackoverflow
Solution 28 - IosgsrView Answer on Stackoverflow