Tell Carthage to create a dependency using Swift 3.2.2 (NOT Swift 4.0)

I have a project written in Swift 3.2.2 and compiled using Xcode 9.1

I have a dependency that is built using Carthage with this command:

carthage update --platform iOS

The problem is that Carthage creates a dependency using Swift 4.0 (instead of Swift 3.2.2)

A module compiled with Swift 4.0 cannot be imported into Swift 3.2.2

How do I tell Carthage to create my dependency using Swift 3.2.2 so that it can be used in my project?

I do not want to upgrade my project to Swift 4.0 yet.

Xcode 9.1 supports both Swift 3 and Swift 4. So, how can I say that Carthage uses Swift 3 when compiling dependencies? I don't want to talk to use an earlier version of Xcode (which I no longer have)

+5
source share
2 answers

You speak:

  • Your project compiles in Swift 3.2.2
  • your dependency, after resolving it and loading it with Carthage, will compile in Swift 4 (since its build configuration was set up this way)

with these conditions it will be impossible to solve the problem: you cannot mix Swift 3 and 4 because of this: https://github.com/Carthage/Carthage/issues/1978

The only thing you can do to (eventually) fix the situation:


Scenario 1

  • you should find the previous version of the library, which is built in Swift 3.2 ~, if exists
  • in your Cartfile you specify this particular version, for example:

    github "yourDependency" == xyz


Scenario 2

  • launch carthage update --platform iOS
  • enter inside the dependency folder ( Carthage/Checkouts/yourDependency ) and open the .xcodeproj file to manually change this option:

enter image description here

  1. then you can have a lot of problems with the construction due to the fact that you are creating a regression of the language, you can try to fix them (depending on the library, if it is small or not, it may be possible).
  2. if you solved the dependencies, then run:

    carthage build --platform iOS

  3. try to compile your project ...
+5
source

The only workaround at the moment is to switch to a new build system in Xcode. In the workspace settings. Or a downgrade version that supports speed 3

0
source

Source: https://habr.com/ru/post/1273411/


All Articles