AliSoftware / OHHTTPStubs

Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers!
MIT License
5.04k stars 601 forks source link

Swift 4 Support #257

Closed the-freshlord closed 7 years ago

the-freshlord commented 7 years ago

New Issue Checklist

Environment

Issue Description

Hello,

When trying to install OHHTTPStubs on a project using Swift 4, I come across this error with the Swift versions being different. Will there be an update for supporting Swift 4? Here is a screenshot of the error: screen shot 2017-09-21 at 5 25 07 pm

Liquidsoul commented 7 years ago

Hi @eman6576,

From the error, it does not seem to be related to the OHHTTPStubs library but to its integration with cocoapods. You are adding OHHTTPStubs as a dependency to targets with different Swift versions and it appears that cocoapods cannot handle this (or at least the version you use). Could you try using the same swift version in your targets? Or If not possible, just remove temporarily BaseAppV2IntegrationTests to see if it works with only Swift 4.0 integration?

Thanks!

the-freshlord commented 7 years ago

@Liquidsoul ,

I was able to compile by making all targets use Swift 4.0. I also forked OHHTTPStubs, migrated to Swift 4.0 and changed its targets to Swift 4.0.

Liquidsoul commented 7 years ago

I do not understand your need to have a fork here 🤔 I tried to use the 6.0.0 version using cocoapods 1.3.1 on a project configured to use Swift 4.0 and everything seems to be working fine. Could you check that on your end? And in any case, if your problem is solved, please close the issue 🙇

dimazen commented 7 years ago

Hello, @Liquidsoul. Any chances to update OHHTTPStubs archive for the Carthage download (the one attached to the release)? It is compiled with Swift 2.2 which is quite old for today :)

AliSoftware commented 7 years ago

We decided to stop shipping precompiled binary releases due to the ABI stability not being there yet for Swift (otherwise we'd have to maintain one for each Swift version to make everyone happy and I don't have that maintenance bandwidth)

AliSoftware commented 7 years ago

Closing this as it's not an issue which requires any action by OHHTTPStubs itself, but by Carthage relying on the Swift ABI being stable while it's not.

This issue is thus common to any Swift library that you integrate with Carthage and provides a compiled binary, not just OHHTTPStubs. To solve it just use the --no-use-binaries flag when invoking Carthage, or open an issue in the Carthage repo to all them to auto-fallback to that flag in case of binary ABI incompatibility detected (I thought they already implemented that fallback though so be sure to use the latest version of Carthage too)