Carthage: Incompatible Swift version - framework was built with 4.2 and the local version is 4.2.1

Created on 31 Oct 2018  路  27Comments  路  Source: Carthage/Carthage

  • carthage install method: [ ] .pkg, [ x] homebrew, [ ] source
  • which carthage:/usr/local/bin/carthage
  • carthage version: 0.31.2
  • xcodebuild -version: Xcode 10.1\Build version 10B61
  • Are you using --no-buildno
  • Are you using --no-use-binariesno
  • Are you using --use-submodulesno
  • Are you using --cache-buildsno
  • Are you using --new-resolverno

Cartfile

github "Alamofire/Alamofire" ~> 4.7
binary "https://s3-eu-west-1.amazonaws.com/spitch-mobile-sdk/iOS/SpitchMobileSdk.json" ~> 3.0.1

Carthage Output

*** Downloading binary-only framework SpitchMobileSdk at "https://s3-eu-west-1.amazonaws.com/spitch-mobile-sdk/iOS/SpitchMobileSdk.json"
*** Fetching Alamofire
*** Checking out Alamofire at "4.7.3"
*** xcodebuild output can be found in /var/folders/5k/__1fz935279_66fy153r7h4r0000gn/T/carthage-xcodebuild.lD60hj.log
*** Downloading binary-only framework SpitchMobileSdk at "https://s3-eu-west-1.amazonaws.com/spitch-mobile-sdk/iOS/SpitchMobileSdk.json"
Incompatible Swift version - framework was built with 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1) and the local version is 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1).

Actual outcome
Carthage refused update

Expected outcome
Carthage should update my custom binary framework

I'm building my own framework and distributing it as binary, after upgrading to latest Xcode version, I built my framework with carthage build --no-skip-current and carthage archive and uploaded the .zip file to s3 as usual, but after trying to update dependencies in my projects using my custom framework gives the described output. There is no 4.2.1 option in Swift Language Version inside build settings.

question

Most helpful comment

I was about to report this same issue as a feature proposal: Support disabling swift version validation.

I have a central build machine for producing binary dependencies on Xcode10.0, and a local dev machine that recently updated to Xcode10.1. Ordinarily, we keep these in sync by necessity, but as the compiler occasionally maintains backwards binary compatibility over dot releases, I might upgrade locally earlier than the central machine (I don't control that machine).

Swift 4.2 (Xcode 10) binaries seem compatible with 4.2.1 (Xcode 10.1).

It would be nice to introduce a flag --no-version-validation, so that dependencies which I know are compatible may be allowed.

All 27 comments

can you please run

$ swift version

The output is Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
Target: x86_64-apple-darwin18.0.0

I'm afraid this is not a bug. This is working as intended.
if the toolchain changes, the cache is invalidated.

And have any guess why is this happening and how to solve it? I can鈥檛 find any solution...

Check the -Swift.h in Headers of the binary. What does that say? I'm guessing it says

Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)

Yes

So to confirm:

After upgrading to latest Xcode version, I built my framework with carthage build --no-skip-current and carthage archive and uploaded the .zip file to s3 as usual

You are __absolutely sure__ you built the framework with the __SAME__ version for Xcode you have currently selected?

Please verify the output of

$ xcode-select -p

Then paste here the __relevant__ contents of the -Swift.h in Headers of the binary you are downloading

Then paste here the __relevant__ the output of the following:

$ dwarfdump -arch=armv7 --debug-info <path/to/dSYM> | grep AT_producer

If you feel like giving this a shot, you can try with the patched build of https://github.com/Carthage/Carthage/pull/2622 available here https://github.com/blender/Carthage/releases/tag/swiftz-cache-invalidation

If you don't trust that binary the you can build the PR on your own machine and try.

Please verify the output of

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

Then paste here the relevant contents of the -Swift.h in Headers of the binary you are downloading

// Generated by Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgcc-compat"

#if !defined(__has_include)
# define __has_include(x) 0
#endif
#if !defined(__has_attribute)
# define __has_attribute(x) 0
#endif
#if !defined(__has_feature)
# define __has_feature(x) 0
#endif
#if !defined(__has_warning)
# define __has_warning(x) 0
#endif

#if __has_include(<swift/objc-prologue.h>)
# include <swift/objc-prologue.h>
#endif

#pragma clang diagnostic ignored "-Wauto-import"
#include <objc/NSObject.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

#if !defined(SWIFT_TYPEDEFS)
# define SWIFT_TYPEDEFS 1
# if __has_include(<uchar.h>)
#  include <uchar.h>
# elif !defined(__cplusplus)
typedef uint_least16_t char16_t;
typedef uint_least32_t char32_t;

Then paste here the relevant the output of the following:

$ dwarfdump -arch=armv7 --debug-info | grep AT_producer

output.txt

And the contents of the .version file? Sorry I forgot.

I can't find it, where should be it located?

Actually you don't need it but again this is the problem right here:

... was built with __4.2__ (__swiftlang-1000.11.37.1__ clang-1000.11.45.1)
... local version is __4.2.1__ (__swiftlang-1000.11.42__ clang-1000.11.45.1)

I'm pretty positive the binary was not built with the same version of Xcode you are using atm.

I've rebuilt and uploaded .zip again (I have only one version of Xcode installed) and result is the same

Then I think we have a bug here. Do you want to take a shot at this?

It's pretty easy to get started

The problem should be around https://github.com/Carthage/Carthage/blob/master/Source/CarthageKit/Xcode.swift#L73

I was about to report this same issue as a feature proposal: Support disabling swift version validation.

I have a central build machine for producing binary dependencies on Xcode10.0, and a local dev machine that recently updated to Xcode10.1. Ordinarily, we keep these in sync by necessity, but as the compiler occasionally maintains backwards binary compatibility over dot releases, I might upgrade locally earlier than the central machine (I don't control that machine).

Swift 4.2 (Xcode 10) binaries seem compatible with 4.2.1 (Xcode 10.1).

It would be nice to introduce a flag --no-version-validation, so that dependencies which I know are compatible may be allowed.

@miibpa I had the same problem. I fixed with rm -rf ~/Library/Caches/org.carthage.CarthageKit

Thank you @cannaz This solved the issue for me too!

@miibpa Agree with @sstadelman It will be great to propose a "--no-version-validation" option command.

thx

Yeah especially now that Apple has finally gotten their act together for ABI compatibility. This sort of check loses its meaning and only serves to frustrate since everything needs to be dropped when Apple suddenly decides to make a Swift version bump so that we can make a new Carthage build (which then needs to get run through QE, etc).

ABI stability is not related to this; which is about runtime. What we want here is Module stability; which is about compile time. I recommend you to check the Swit.org blog entry: https://swift.org/blog/abi-stability-and-more/.

Oh, you are right! Great...so Apple is not quite done screwing us around yet....but is it safe to say when (if...) module stability ever comes around that this check will be removed?

It won鈥檛 be removed. It will be relaxed for compatible versions.

I'm sorry guys, I'm a newbie in iOS dev. Can someone explain me how to make it work? I have just exactly everything the same problems.

@fr33z3 recompile the dependency with the appropriate version of the swift compiler

"Incompatible Swift version - framework was built with 4.0.2 (swiftlang-900.0.69.2 clang-900.0.38) and the local version is 5.1.2 (swiftlang-1100.0.278 clang-1100.0.33.9)."

how to get rid of installation errors?

@tmspzz is there a way uploaded binary zips can include multiple versions as compiled by different versions of Xcode? Is this something that is already supported? Or that you're considering?

Each minor swift version update this is causing major issues as we have 10-20 clients who are requiring me to use various different versions of Xcode so only 10% of them maybe I'm able to make use of pre-compiled binaries without having swift version dependent releases in GitHub :(

uploaded binary zips can include multiple versions as compiled by different versions of Xcode

No, it's not supported. I don't think this is desirable.

Each minor swift version update this is causing major issues as we have 10-20 clients who are requiring me to use various different versions of Xcode so only 10% of them maybe I'm able to make use of pre-compiled binaries without having swift version dependent releases in GitHub :(

Is this for private use? Try https://github.com/tmspzz/Rome you can store artifacts per compiler version

Was this page helpful?
0 / 5 - 0 ratings