Moya support for Swift 4 with RxSwift ?

Created on 22 Aug 2017  Â·  17Comments  Â·  Source: Moya/Moya

I am using the following pods. How to make RxSwift and Moya go hand in hand in Swift 4 ?

pod 'RxSwift', :git => 'https://github.com/ReactiveX/RxSwift.git', :branch => 'swift4.0'
pod 'RxCocoa', :git => 'https://github.com/ReactiveX/RxSwift.git', :branch => 'swift4.0'
pod 'Moya/RxSwift', :git => 'https://github.com/Moya/Moya.git', :branch => '9.0.0-dev'

[!] Unable to satisfy the following requirements:

  • RxSwift (fromhttps://github.com/ReactiveX/RxSwift.git, branchswift4.0) required by Podfile
  • RxSwift (= 4.0.0-alpha.1) required by Podfile.lock
  • RxSwift (~> 4.0.0-alpha.1) required by RxCocoa (4.0.0-alpha.1)
  • RxSwift (= 1.4) required by Moya/RxSwift (1.1.0)
question rxmoya

Most helpful comment

Hey again, @aninhakrieger, @linbx08, @neoD1! I've created a branch that is fully Swift 4.0.0-compatible! Branch name: 10.0.0-dev (more info and CocoaPods install steps at #1253). Let me know if it's working for you :)

All 17 comments

Hey @neoD1, thanks for the issue. I guess you are right - we cannot support Swift 4.0 with RxSwift and Moya 9.0. This is because we probably gonna release it before Swift 4.0 and RxSwift 4, and after the new releases we will update our extensions.

Right now we offer Moya core working with Swift 4.0 (on branch 9.0.0-dev for a while yet) or Moya with Swift 3.2 that should work correctly with RxSwift 3.3+. Sorry for the inconvenience!

If you have any more questions, let me know.

:'(

Wait for the day is long, hope Moya support for Swift 4 with RxSwift the truth will become soon .

Hey guys, @aninhakrieger, @linbx08, @neoD1! Just a heads-up that today we are planning to release version 9.0.0 and immediately after we will start with development branch for 10.0.0, which will include support for Swift 4.0 and reactive extensions. We will update this issue once we get something working.

Ah Fantastic! Thanks a lot

Hey again, @aninhakrieger, @linbx08, @neoD1! I've created a branch that is fully Swift 4.0.0-compatible! Branch name: 10.0.0-dev (more info and CocoaPods install steps at #1253). Let me know if it's working for you :)

Very thankful to you

Thank you !!! Will keep you posted , if something comes up.

In the new version, Moya instead of subscribing to a Single with the three methods use to respond to notifications from an Observable (onNext, onError, and onCompleted), so that we only need use two methods to subscribe(onSuccess, onError).Ah Fantastic! Sadly, we need to upgrades the code

@sunshinejr tried today installing Moya from 10.0.0-dev branch using Carthage. But can't build my project, because framework is compiled with Swift 3.1.
screen shot 2017-09-08 at 18 27 57

@Alexey-Matjuk did you update from an existing project? You might need to delete your Derived Data in that case.

@BasThomas thanks, it false alarm.
I cleaned Derived data before my first comment, but didn't think of Derived Data of Moya itself. Now it works.

@sunshinejr tried fetching Moya from "10.0.0-dev" branch using Carthage, but couldn't get Moya in ios Build. Also when will it be available in Release?
error - Build Failed
Task failed with exit code 65:
/usr/bin/xcrun xcodebuild -workspace /Users/xxxx/Desktop/project/Carthage/Checkouts/RxSwift/Rx.xcworkspace -scheme RxBlocking-iOS -configuration Release -derivedDataPath /Users/xxxx/Library/Caches/org.carthage.CarthageKit/DerivedData/RxSwift/4.0.0-alpha.1 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build (launched in /Users/xxx/Desktop/ProjectName/Carthage/Checkouts/RxSwift)

Sorry I still don't know the correct practice, my podfile is as follows:

pod 'Alamofire',   '~> 4.5'
pod 'RxSwift',     '~> 4.0.0-beta.0'
pod 'RxCocoa',     '~> 4.0.0-beta.0'
#pod 'Moya',        '~> 9.0'
pod 'Moya/RxSwift', :git => 'https://github.com/Moya/Moya.git', :branch => '10.0.0-dev'

And the error messge is :
[!] There are multiple dependencies with different sources for Moya in Podfile:

  • Moya (~> 9.0)
  • Moya/RxSwift (from https://github.com/Moya/Moya.git, branch 10.0.0-dev)

How to modify it? thanks

@leiguang Did you run pod update after changing the Podfile?

After pod update, it prompts:
[!] There are multiple dependencies with different sources for Moya in Podfile:

  • Moya (~> 9.0)
  • Moya/RxSwift (from https://github.com/Moya/Moya.git, branch 10.0.0-dev) @pedrovereza

Thank you, it is now working properly like this:

pod 'RxSwift',     ‘4.0.0-alpha.1’
pod 'RxCocoa',     ‘4.0.0-alpha.1’
pod 'Moya/RxSwift', :git => 'https://github.com/Moya/Moya.git', :branch => '10.0.0-dev'
Was this page helpful?
0 / 5 - 0 ratings