Rxswift: RxCocoa error in Xcode 10 (`Cycle inside RxCocoa; building could produce unreliable results.`)

Created on 14 Jun 2018  路  31Comments  路  Source: ReactiveX/RxSwift

I get the following error, when I try to build a project that has RxCocoa as a dependency. 馃

screenshot 2018-06-14 at 14 03 57

RxSwift/RxCocoa/RxBlocking/RxTest version/commit

  4.0

Platform/Environment

  • [x] iOS
  • [ ] macOS
  • [ ] tvOS
  • [ ] watchOS
  • [ ] playgrounds

How easy is to reproduce? (chances of successful reproduce after running the self contained code)

  • [x] easy, 100% repro
  • [ ] sometimes, 10%-100%
  • [ ] hard, 2% - 10%
  • [ ] extremely hard, %0 - 2%

Xcode version:

  Xcode 10

Level of RxSwift knowledge:
(this is so we can understand your level of knowledge
and formulate the response in an appropriate manner)

  • [ ] just starting
  • [ ] I have a small code base
  • [x] I have a significant code base
help wanted

Most helpful comment

@netbe Have you run pod update? Maybe, you've got outdated local specs repos. pod 'RxSwift', '~> 4.3' should work too and is more advisable

All 31 comments

Hi @jdisho ,

have no idea, PRs are welcome. I've created a new branch for Xcode10.

Appkit and UIKit has API changes in Swift 4.2. @kzaher, new branch Xcode10 will be for Swift 4.2?
@jdisho, has you try change swift version from 4.2 to 4.0 _RxCocoa_ target in Pod project?

@carlosypunto I think we should first figure out how to fix it, and if it's possible to make compatible changes with Xcode 9, then we'll use the same branch, otherwise we'll think about it more.

Ok @kzaher. I took a little while and did the update, basically the problem is with RxCocoa and RxExample, since RxSwift is Swift 4.2 code compatible. I could not pass the tests because (like in #1677 issue) runnin ./scripts/package-spm.swift twice don't make the same content of Sources/AllTestz/main.swift so it will always modify the git working copy stoping the tests. I hope I have clarified something.

Swift 4.2 implements SE-0206, which changes the way they make custom types conform to the Hashable protocol. It introduces a new Hasher struct that provides a randomly seeded, universal hash function to make this process easier:

Hasher uses a random seed every time it hashes an object, which means the hash value for any object is effectively guaranteed to be different between runs of your app.

This in turn means that elements you add to a set or a dictionary are highly likely to have a different order each time you run your app.

Thus I suspect that due to this, the function buildAllTestsTarget in ./scripts/package-spm.swift is no longer deterministic, and as such generates a different result every time that it's run.

As mentioned in #1676, buildAllTestsTarget in ./scripts/package-spm.swift is no longer deterministic and as such generates a different set of results every time that it's run.

package-spm.swift needs the following changes:

-    for (name, methods) in reducedMethods {

+    for name in reducedMethods.keys.sorted() {
+        let methods = reducedMethods[name]!

and

-    for testCase in reducedMethods.keys {

+    for testCase in reducedMethods.keys.sorted() {

I'd submit a PR to fix this, but PRs can't be submitted due to this issue.

PR #1676 Add bag to dispose bag includes this fix. After adding all checks passed.

Cool. If the _Xcode 10_ branch going to keep Swift 4.0 in future versions, is no longer necessary, the _develop_ branch is ready for _Xcode 10_ only using the next hook.

platform :ios, '9.0'
use_frameworks!

target 'TestRxSwift' do
  pod 'RxSwift', :git => 'https://github.com/ReactiveX/RxSwift.git', :branch => 'develop'
  pod 'RxCocoa', :git => 'https://github.com/ReactiveX/RxSwift.git', :branch => 'develop'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |configuration|
      configuration.build_settings['SWIFT_VERSION'] = "4.0"
    end
  end
end

@kzaher, if you want _Xcode 10_ branch will be ready for Swift 4.2, I can make the conversion. Do I it?

I solved this issue by cleaning the build folder, clearing pods cache, re-install all pods, and then rebuilding.

Just an FYI, but Xcode 10 beta 2 has a known issue regarding build cycles in the new build system. It's in the release notes.

As far as I can tell this works now.

Hi, I am still getting this error on Xcode 10 and swift 4.2 using cocoapods:

 pod 'RxSwift', '4.3.1'
 pod 'RxCocoa', '4.3.1'

@netbe Have you run pod update? Maybe, you've got outdated local specs repos. pod 'RxSwift', '~> 4.3' should work too and is more advisable

I still see this problem in 4.4.0, is there an actual fix? or is this just xcode being xcode?

I solved this issue by cleaning the build folder, clearing pods cache, re-install all pods, and then rebuilding.

Have you tried this? @nicktrienensfuzz

Sent with GitHawk

@jdisho that's only a temporary fix, it will happen again

Anybody has an idea how to solve this?

It doesn't happen a ton in my experience at least, and I don't see it being a RxSwift issue, but a Xcode/Swift issue. Proof of that being that cleaning derived data solves this.

I guess it could still be our issue somehow, but I have no idea what to do.

I think this post could help you. It states xcode 9 but you can take it as 9 or newer

Our organization has switched back to legacy build across the board due to seeing this in rxcocoa and rxswift to avoid clearing derived data every other build. Last time I saw it the cycle was rxoptional -> rx cocoa -> rxoptional.

If this can be reproduced with RxOptional, I'd love to tackle this.
I don't have the time to build 100 times until I find it, and in our project we don't experience this error. (Not using RxOptional, though)

We had seen this previously when using CocoaPods and when the main project used RxSwift and RxCocoa and that project included a pod that also had RxSwift and RxCocoa as a dependency. The lead there is out, so I'm not sure if the team switched to legacy build or if they simply imported the code directly and dropped the pod.

At any rate it seemed to be related to the Compile Sources / Build Phases issue mentioned in the above link.

other problem

Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "RxCocoa":
In Podfile:
RxCocoa (~> 5)

None of your spec sources contain a spec satisfying the dependency: RxCocoa (~> 5).

You鈥檙e probably directing your Podfile directly to master. If your remove that and target 4.5 you should be fine.

@jdisho Or any other person with this issue, could any of you try Xcode 10.2 with the develop branch and see what's your status with it?

I can give this a try! @freak4pc

@jdisho Had a chance?

Is anyone still experiencing this?

Personally, I can't and I am using Xcode 10.2.

Let's close this for now and if we encounter it in future, we can reopen it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RafaelPlantard picture RafaelPlantard  路  3Comments

angerman picture angerman  路  3Comments

hannesstruss picture hannesstruss  路  3Comments

jaumard picture jaumard  路  3Comments

gekitz picture gekitz  路  3Comments