Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible Swift version - framework was built with 4.2 and the local version is 4.2.1 #2632

Closed
miibpa opened this issue Oct 31, 2018 · 27 comments
Labels

Comments

@miibpa
Copy link

miibpa commented Oct 31, 2018

  • 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.

@tmspzz
Copy link
Member

tmspzz commented Oct 31, 2018

can you please run

$ swift version

@miibpa
Copy link
Author

miibpa commented Oct 31, 2018

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

@tmspzz
Copy link
Member

tmspzz commented Oct 31, 2018

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

@miibpa
Copy link
Author

miibpa commented Oct 31, 2018

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

@tmspzz
Copy link
Member

tmspzz commented Oct 31, 2018

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)

@miibpa
Copy link
Author

miibpa commented Oct 31, 2018

Yes

@tmspzz
Copy link
Member

tmspzz commented Oct 31, 2018

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

@tmspzz
Copy link
Member

tmspzz commented Oct 31, 2018

If you feel like giving this a shot, you can try with the patched build of #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.

@miibpa
Copy link
Author

miibpa commented Oct 31, 2018

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 <path/to/dSYM> | grep AT_producer

output.txt

@tmspzz
Copy link
Member

tmspzz commented Oct 31, 2018

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

@miibpa
Copy link
Author

miibpa commented Oct 31, 2018

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

@tmspzz
Copy link
Member

tmspzz commented Oct 31, 2018

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.

@miibpa
Copy link
Author

miibpa commented Oct 31, 2018

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

@tmspzz
Copy link
Member

tmspzz commented Oct 31, 2018

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

@sstadelman
Copy link

sstadelman commented Oct 31, 2018

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.

@nazz-areno
Copy link

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

@miibpa
Copy link
Author

miibpa commented Nov 20, 2018

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

@miibpa miibpa closed this as completed Nov 20, 2018
@gigaga
Copy link

gigaga commented Mar 14, 2019

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

thx

@borrrden
Copy link

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).

@ikesyo
Copy link
Member

ikesyo commented Apr 23, 2019

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/.

@borrrden
Copy link

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?

@tmspzz
Copy link
Member

tmspzz commented Apr 23, 2019

It won’t be removed. It will be relaxed for compatible versions.

@fr33z3
Copy link

fr33z3 commented Jul 15, 2019

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.

@tmspzz
Copy link
Member

tmspzz commented Jul 15, 2019

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

@avanes5555
Copy link

"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?

@simonmitchell
Copy link

@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 :(

@tmspzz
Copy link
Member

tmspzz commented Nov 11, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants