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.03k stars 601 forks source link

Incompatible Swift version - framework was built with 3.1and the local version is 4.1 #277

Closed bhargavi-k closed 6 years ago

bhargavi-k commented 6 years ago

New Issue Checklist

Environment

Issue Description

I updated to Xcode 9.3 and Swift 4.1 and then removed Carthage folder and ran carthage update --platform IOS. I expected it to download and install the dependency but it came back with the following error.

*** Skipped installing OHHTTPStubs.framework binary due to the error: "Incompatible Swift version - framework was built with 3.1 (swiftlang-802.0.53 clang-802.0.42) and the local version is 4.1 (swiftlang-900.0.74.1 clang-900.0.39.2)."

AliSoftware commented 6 years ago

When installing any library with Carthage, OHHTTPStubs included, you'll have to use the --no-use-binary flag of Carthage in order to be able to have the same ABI / Swift Version as your project.

This is because Carthage otherwise doesn't consider the fact that Swift isn't ABI-stable yet, and it's impossible to make pre-build binaries of libraries (like OHHTTPStubs or any other) ABI-stable yet, so when Carthage tries to download a pre-build binary there's no guarantee to download the pre-build binary of the right Swift ABI version. Allowing to do that would require us to re-publish a new pre-build binary every time a new Swift version is out, including beta versions, while Carthage only allows to publish one pre-build binary for each version of each lib. Even if we had the bandwidth to do that and decide to publish the pre-build binary of the latest version every time, that would mean that other users potentially not ready to update to the latest Xcode for other reasons would have the same problem and we wouldn't be able to content everybody anyway.

Using the --no-use-binary flag of Carthage will force Carthage to not use the pre-build binary (which will almost never be the right Swift ABI version for everybody anyway) and instead re-build the library from source using your own current Swift version, ensuring it's ABI-compatible just for that current version. This tip is valid for any library integrated with Carthage, not just OHHTTPStubs.

ikesyo commented 6 years ago

And also the message is just an info or warning, not an error. Carthage automatically falls back to build the framework locally.