Home » Swift » Cocoa pod installation error: “ The target overrides the SWIFT_VERSION build setting ”

Cocoa pod installation error: “ The target overrides the SWIFT_VERSION build setting ”

Posted by: admin November 30, 2017 Leave a comment

Questions:

I’m trying to install Cocoalumberjack as a pod and am getting this error:

The ProjectName [Release] target overrides the SWIFT_VERSION build
setting defined in `Pods/Target Support
Files/Pods-ProjectName/Pods-ProjectName.release.xcconfig’. This can
lead to problems with the CocoaPods installation

The pod xcconfig file contains this:

SWIFT_VERSION = 3.0

But my project is already using swift 3. so I don’t understand why there’s this mismatch.

xcrun swift -version

Apple Swift version 3.0 (swiftlang-800.0.46.2
clang-800.0.38)

However I cannot see a SWIFT_VERSION in particular anywhere in Xcode’s build settings, nor if I type in swift as the search term in the Xcode’s build settings can I see anything anywhere that even looks like a swift version number

Additionally the pod installation goes on to say:”Use the $(inherited) flag” to solve the problem.
However my Xcode build settings other linker flags already has this $(inherited) flag, so why is that not solving the problem?

(Xcode 8)

Answers:

It is a bit non-intuitive but what you have to do is:

1) Search for “SWIFT_VERSION” in your project settings

2) you will see an entry saying “Use Legacy Swift Language Version”

  • If you had already selected any value it will be shown in BOLD

3) Select the entry (not the value) and press “DELETE”, the boldness should disappear.

4) Repeat the same steps but now for your target (the one with the app icon)

5) Close XCode

6) Run “pod install” again

7) Open your project, and CLEAN IT (Shift + Command + K)

Now it should be working correctly.

NOTE:

Specifically for “Cocoalumberjack” make sure your pod is installing the 3.0+ version, if its not run a “sudo pod update” as versions previous to this won’t work with Swift 3.

EDIT:

I’m pretty sure the cocoapods handling of this is a bit buggy at the moment, as I’ve experienced sometimes it works and others it doesnt. However, keep in mind you can set the “SWIFT_VERSION” flag directly on a per framework basis:

1) Select the Pods project (within your project).

2) Select the target that you want to set and look for the “SWIFT_VERSION” flag specifically for that target.

3) Clean and rebuild.

Questions:
Answers:

You need to remove any overridden “Use Legacy Swift Language Version” build setting from your targets.

Questions:
Answers:

That is not exactly helpful as there is no way to remove it.

You either inherit the value, or you assign a value, and there is no way to get back to $(inherited) value after an assignment due to the way the UI is built on xcode (on some options you have a “custom” value where you can add this, but not on all kinds of values).

So it’s kind of a dead end with no real solutions.