Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)

like image 736
Gruntcakes Avatar asked Sep 23 '16 18:09

Gruntcakes


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

like image 125
Pochi Avatar answered Nov 20 '22 01:11

Pochi


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

like image 21
Spi Avatar answered Nov 20 '22 00:11

Spi