问题
I am trying to move to the new build system when compiling with Xcode 10. However, it gives 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'
Even after removing the problem file, I get same for another xib/storyboard. How can I solve this error without reverting to the legacy build system?
回答1:
For anybody having an issue with Xcode 10 build system, follow the following steps to fix it:
- In Xcode, go to File->Project/Workspace settings.
- 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.
回答2:
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.
回答3:
I fixed my problem by moving the 'Copy Bundle Resources' Build Phase before all my 'Copy Files' & 'Link Binary with Libraries' Build Phases
回答4:
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.
回答5:
I was having this issue with Cocoapods and found a temporary workaround:
- Install latest version of cocoapods (1.5.3):
sudo gem update cocoapods
- Delete you derived data:
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod install
Source here and I'm on Xcode 10 beta 4.
EDIT: now on Xcode 10.0 and still relevant.
回答6:
I was finally able to resolve this by moving Embed App Extensions
script in Build Phases
of main Target to last position.
回答7:
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.
回答8:
In the target's Scheme
, find the label Build
, and ensure that Find Implicit Dependencies
is not checked. These steps may work.
回答9:
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!
回答10:
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.
Xcode 10.2 & Swift 5
回答11:
My solution was simply to Clean Build Folder then re-build.
回答12:
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.
回答13:
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.
回答14:
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
回答15:
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
回答16:
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.
回答17:
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
.
回答18:
You might be able to fix this here:
File -> Workspace Settings -> Build System: New Build System
回答19:
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.
回答20:
I solved this by moving the "Run Script" to the top of the build phases.
回答21:
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.
来源:https://stackoverflow.com/questions/50709330/cycle-inside-building-could-produce-unreliable-results-xcode-10-error