Moya on Swift 2.3 & 3.0.

Created on 18 Jun 2016  Â·  16Comments  Â·  Source: Moya/Moya

Took a crack at checking out swift 2.3 support this morning...

The good news:

  • Apple's migrator tool is great, after running on Moya, the demo target and tests (iOS,tvOS) built and worked/passed
  • The changes don't look too bad from Moya's end
  • Foundation Value types and the new Swift API Guidelines don't come into play until Swift 3 which greatly limits changes.
  • swift 2 and 2.3 can live side by side with #if swift(>=2.3) ...

    The meh news:

  • Nimble under macOS had some issues I've seen reported as Xcode/Foundation related -- affects macOS test target

  • xcodebuild doesn't pick up the swift legacy flag which triggers a compile against a 2.0 toolchain Xcode _should_ in the future hopefully not do this. Until then rake build and rake test don't work without setting the TOOLCHAINS Environment flag. This is probably a bug in xcodebuild.
  • Relatedly Setting of the legacy swift flag is not performed by the migrator maybe because they want 2.0/2.3/3.0 to try and live side by side but that will cause weirdness with dependent projects.

So tracking what happened when I got it all building:

  • _Moya Changes:_
  • [ ] A couple URL API's changed nullability. Should check documentation and expectations and see if implicitly unwrapped is safe. Most are similar to:
 public func url(route: TargetType) -> String {
-    return route.baseURL.URLByAppendingPathComponent(route.path).absoluteString
+    return route.baseURL.URLByAppendingPathComponent(route.path)!.absoluteString!
 }

P.S. It's been a while since I ran Moya in dev mode and it took me a little while to get oriented, do you guys think a quick _Getting Started With Developing Moya_ section somewhere would be useful? maybe #270. I don't really use rake for build scripting so it took a bit to get that setup.

chore enhancement

Most helpful comment

I highly recommend a Swift 2.3 build, even as a version bump, before going to Swift 3. Alamofire had breaking changes so without this people won't be able to use pre-Swift 3 on Xcode 8. I know I'll be using Xcode 8 and Swift 2.3 for a while after the release.

All 16 comments

RxSwift: ??

With ReactiveX/RxSwift@9b1583f2e365ef78d250be278ca5838076b58095 RxSwift supports Swift 2.3. It doesn't have the correct build flag.

This is great work and a nice comprehensive write-up, thanks @aaroncrespo!

Another thing to think about is if it makes sense to skip 2.3 and go straight to 3.0 or how to support 3 versions. The #if swift() tests don't work so well when swift 3.0 is in the mix.

Sorry about the accidental closure. Misunderstood what 'Close' meant in a third-party GitHub client. Was just trying to close the issue view. 😳

No problem, it happens!

I highly recommend a Swift 2.3 build, even as a version bump, before going to Swift 3. Alamofire had breaking changes so without this people won't be able to use pre-Swift 3 on Xcode 8. I know I'll be using Xcode 8 and Swift 2.3 for a while after the release.

I've changed the title due to #522 discussion.

Aye, think it's worth shipping a 2.3 dupe of current Moya, one the Rx deps have them, then moving to 3.0

That makes sense – should we make 2.3 version off of master or the most recent commit? (master has breaking changes.)

Maybe the last stable release?

Looks like Alamofire is about to cut a 3.5.0 release which will have both swift 2.2 and swift 2.3 support. Then Moya.spec can point to that.

https://github.com/Alamofire/Alamofire/milestone/27

I think this is the dependency to push a release supporting 2.3

Is there any update on swift 3.0 support now that Xcode 8 GM is out

Need swift 2.3 and swift 3.0 support here...

We will have to wait before updating to the GM Seed version:

  • [x] [RxSwift#869](https://github.com/ReactiveX/RxSwift/pull/869)
  • [x] [Result](https://github.com/antitypical/Result) update

Edit: I've opened #608 for Swift 3.0 support.

@sunshinejr It seems Result already is Swift 3. :)

This looks like it's been solved with the 8.0.0 beta releases, I'm going to close it out. Please feel free to open this if there are any loose ends!

Was this page helpful?
0 / 5 - 0 ratings