Carthage Build Failed
Check your application folder and Switch your Xcode version to older version with swift 3.
sudo xcode-select --switch /Applications/Xcode.app
TL;DR: Ensure you're using the latest Swift version, included with Xcode, and then perform carthage bootstrap --no-use-binaries --platform iOS --cache-builds
Long version:
The error you got from Xcode while building your project, Incompatible Swift version - framework was built with 3.1 and the local version is 4.0
, is due to a download performed by Carthage to get a pre-built version of Realm Framework (this is a time-saver feature but sometimes there are version incompatibilities like this one).
This downloaded pre-built framework was compiled with a previous version of Swift (in this case the error is pointing v3.1 was used.) The solution for this error will be to perform the dependencies installation process using a different command:
carthage bootstrap --platform iOS --no-use-binaries
This will work for the project dependencies build to succeed. Anyway this might take a long time since it will build from scratch the Realm.framework and RealmSwift.framework from the core every time the command is executed. So it is possible to enable a local cache for the builds on Carthage. The dependencies can be installed with
carthage bootstrap --no-use-binaries --platform iOS --cache-builds
With this options Carthage will:
- bootstrap, so the versions in the
Cartfile.resolved
will be used, no updates. --no-use-binaries
build the dependencies with no downloads of pre-built frameworks (avoiding the version incompatibility.)--platform iOS
will build the dependencies for be used only on iOS, avoiding building frameworks for Apple TV or Mac OS in case the dependency supports it. This will cut a lot of time!--cache-builds
will enable Carthage to store your built dependencies (and use it when re-needed) on a local cache, so even if you perform the command again it will just copy your stored framework, avoiding another time consuming build process.