117

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?

Sahil Kapoor
  • 11,183
  • 13
  • 64
  • 87

31 Answers31

55

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.

Akshay Sunderwani
  • 12,428
  • 8
  • 29
  • 52
  • 82
    The whole point of the question is to move to the latest build system. – Sahil Kapoor Jun 29 '18 at 06:32
  • 5
    Then you should mention that in question that you don’t want solution with changing the build system. Also, I have mentioned that if you want to work with new build system then you can follow steps given at Xcode support center. Also, provide a valid reason when you downvote. Thanks! @SahilKapoor – Akshay Sunderwani Jun 29 '18 at 11:38
  • 2
    Thank you kind stranger. My only interest is getting my build working again to hit a deadline so your answer is exactly what I needed. – Dan Loughney Oct 16 '18 at 21:23
  • 10
    This is not an appropriate solution to the problem. The build system should not be changed to Legacy for something this simple. – Varun Goyal Feb 01 '19 at 18:44
  • 1
    Do NOT follow these instructions. This is incorrect. There's a hint in the name: "Legacy" - in fact, it's been deprecated and no longer supported going forward. – strangetimes Jun 22 '22 at 10:08
51

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.

JAL
  • 41,701
  • 23
  • 172
  • 300
47

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

Shamrai Aleksander
  • 13,096
  • 3
  • 24
  • 31
ShevaKuilin
  • 479
  • 4
  • 3
33

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

gypsyDev
  • 1,232
  • 1
  • 14
  • 22
  • +1 but I used a slight variation. I did not need to move anything ahead of "Link Binary with Libraries", which I would not do because a new default project in Xcode is not like that. I just moved "Copy Bundle Resources" ahead of "Copy Helper Tools" (which copies some command-line tools and a helper app to Contents/Helpers of the macOS app product). But since the order of these two should make any difference – they are only copying files – it does not make sense. So I filed a bug: 42927301. My modified solution: Swap around various Copy XXX Build Phases until it works :( – Jerry Krinock Aug 04 '18 at 07:04
  • 2
    Same for me, I moved my Copy Bundle Resources above the Copy Files phase and presto it works now. I will dupe your bug @JerryKrinock – Peter N Lewis Oct 29 '18 at 07:58
  • For me, the problem was with Embed Frameworks dependencies, so I moved Embed Frameworks above Copy Bundle Resources, and it helped. – Elena Nov 02 '18 at 15:06
25

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.

gabuchan
  • 785
  • 1
  • 7
  • 18
  • it happened to me again last week on Xcode 10.1 (10B61) and it still worked. Make sure to perform a `Clean Build Folder` (and quitting Xcode might help also) before doing steps `2.` and `3.`. – gabuchan Dec 10 '18 at 01:55
  • Worked like a charm! – flagman Jan 10 '19 at 03:52
19

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.

Rick Ballard
  • 4,765
  • 2
  • 19
  • 17
17

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.

Lookaji
  • 1,023
  • 10
  • 21
15

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

Sahil Kapoor
  • 11,183
  • 13
  • 64
  • 87
  • Got this error in Xcode 10.0 beta 4 (10L213o) – this workaround solved it :-) – StackUnderflow Jul 18 '18 at 23:34
  • how to do that ? can you explain it step by step ?, basically, I have a extension for Siri kit in it and can not run application on simulator but it work on the device – Sultan Ali Jun 11 '21 at 12:56
11

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

onemoreanimal
  • 183
  • 2
  • 5
7

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

Ky -
  • 30,724
  • 51
  • 192
  • 308
Nh Xu
  • 123
  • 8
7

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

2) Go to build phases

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

This fixed my issue. Hope it helps!

Nishu_Priya
  • 1,251
  • 1
  • 10
  • 23
4

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.

karolkarp
  • 271
  • 2
  • 7
3

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

3

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:

Objective C, Swift Interoperability issue due to circular dependency

How to prevent circular reference when Swift bridging header imports a file that imports Hopscotch-Swift.h itself

EDIT:

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

Constantine
  • 439
  • 6
  • 10
3

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).

Senseful
  • 86,719
  • 67
  • 308
  • 465
2

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
bcherry
  • 7,150
  • 2
  • 28
  • 37
2

You might be able to fix this here:

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

Workspace Settings

Matt Rowles
  • 7,721
  • 18
  • 55
  • 88
SepCode
  • 63
  • 9
1

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.

vicegax
  • 4,709
  • 28
  • 37
1

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.

Community
  • 1
  • 1
Alireza aj
  • 71
  • 1
  • 11
1

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.

Jimmy
  • 55
  • 5
1

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

Kshama Singh
  • 294
  • 2
  • 4
0

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.

Vladimír Slavík
  • 1,727
  • 1
  • 21
  • 31
0

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

Deepseey
  • 11
  • 1
0

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.

Lucas van Dongen
  • 9,328
  • 7
  • 39
  • 60
0

In my case,

Removed all pods and reinstall resolved the error

Remove Pods directory in ios folder
pod install
0

Only for Expo

  1. expo prebuild --clean
  2. cd ios
  3. pod install
  4. yarn ios
Daniel Danielecki
  • 8,508
  • 6
  • 68
  • 94
0

if you are developing on React-Native, it was the best way for me.

cd ios && rm -rf Pods && pod install && cd ..

lestonz
  • 149
  • 4
0

cd ios && rm -rf Pods && pod install && cd ..

This worked for me.

Muhammad Talha
  • 719
  • 1
  • 4
  • 9
0

I know the original question was asking about pure iOS, but if anyone is running into this issue when trying to run native code with Flutter, try the following:

  1. Run flutter clean in terminal or from the Android Studio menus
  2. Clean your build folder in XCode (Product -> Clean Build Folder)
  3. Comment out every bit of native code that you've added to your main application class that references other files.
  4. Comment out everything except #import "GeneratedPluginRegistrant.h" in your bridging header file ([project name]-Bridging-Header.h by default I think)
  5. Target a simulator and run the app from XCode
  6. Uncomment everything you commented out in steps 3 and 4

That's been fixing it for me.

-1

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.

Marcello B.
  • 4,177
  • 11
  • 45
  • 65
-3

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.

gsr
  • 5
  • 2