Cocoapods: pod update fails with "There may only be up to 1 unique SWIFT_VERSION per target"

Created on 17 Nov 2016  路  17Comments  路  Source: CocoaPods/CocoaPods

Report

What did you do?

pod update

What did you expect to happen?

Install all pod dependencies correctly.

What happened instead?

Pods fail to update.

$ pod update
Update all pods
Updating local specs repositories

CocoaPods 1.2.0.beta.1 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.2.0.beta.1

Analyzing dependencies
[!] There may only be up to 1 unique SWIFT_VERSION per target.

CocoaPods Environment

Stack

   CocoaPods : 1.1.1
        Ruby : ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
    RubyGems : 2.5.1
        Host : Mac OS X 10.12.1 (16B2555)
       Xcode : 8.1 (8B62)
         Git : git version 2.10.2
Ruby lib dir : /Users/dan/.rbenv/versions/2.3.0/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ f36294f4c598ecb4a8a7ba7d1e99944f0eb16e77
               wepay - [email protected]:wepay/mobile-podspecs.git @ 277fce1c76ad03b4063800cea89e041ac1a7d12e

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.1
cocoapods-playgrounds : 1.2.2
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.1.1
cocoapods-try         : 1.1.0

Podfile

platform :ios, '9.0'

source 'https://github.com/CocoaPods/Specs.git'
project 'My App.xcodeproj'

inhibit_all_warnings!
use_frameworks!

target 'My App' do
  pod 'Alamofire', '~> 4.0'
  pod 'AlamofireImage', '~> 3.0'
  pod 'AlamofireNetworkActivityIndicator', '~> 2.0'

  pod 'LionheartExtensions', '~> 2.0'
  pod 'LionheartAlamofireClient', '~> 2.1'
  pod 'QuickTableView', '~> 2.0'
  pod 'LionheartCurrencyTextField', '~> 1.0'

  pod 'TableViewPopoverPresenting', '~> 2.0'
  pod 'FMDB/standalone/FTS', '~> 2.6'
  pod 'KeyboardAdjuster', '~> 1.3'
  pod 'Signature'
  pod 'SHSPhoneComponent'
  pod 'ReachabilitySwift', '~> 3.0'
  pod 'libPhoneNumber-iOS', '~> 0.8'
  pod 'SwiftyUserDefaults', '~> 3.0'

  pod 'Raygun4iOS'
  pod 'Fabric'
  pod 'Crashlytics'
  pod 'Mixpanel'
  pod 'Zip'
  pod 'SentrySwift'

  target 'My App Tests' do
    inherit! :search_paths

    pod 'Nimble', '~> 5.1'
  end
end
easy detailed enhancement

Most helpful comment

Opened up a PR to make this better.

All 17 comments

Did one of your dependencies update to use a different version of Swift? I.e do you use 2.3 of Swift but a pod was updated to use Swift 3.0? The error message is fairly clear.

Yep, understood what the error message is, but the issue is that it's unclear which of the pods is the culprit. Alternatively, letting the installation continue and simply displaying the message as a warning might be preferable since at that point it'll be clear which pod is causing the issue.

Thats a good suggestion, it would be nice to print out the inconsistency.

pods themselves don't have an inherent swift version. They're built using whatever swift version is set for the targets they're going to be integrated into. I'd assume that here your test and app targets have different swift versions set.

Why would that prevent pods from being installed?

Because of the way you have target inheritance setup in your Podfile, those 2 targets (app and test targets) are going to share the Swift frameworks built from the pods (i.e. the pod frameworks). As it currently stands, a Swift binary can only use a Swift framework built using the same version of Swift as the Swift binary that's using it. Therefore, if you have multiple Swift apps all sharing the same Swift framework, all of the targets (frameworks and apps) there must be built using the same version of Swift.

Given that, we have to pick a Swift version for Xcode to use to build the pod targets, which is why you see this error (need to pick 1, but there exists more than 1 version that will share the pods).

Would be nice to list the versions of swift for your targets in the error - @dlo would you like to try make a PR for this?>

I'm having some trouble using the Rainforest repo to set up a local dev environment. Running into a few issues during rake bootstrap鈥攇etting an error installing the JSON gem (1.7.7) and getting another message that cocoapods-docs-0.2.0 requires ruby version = 2.0 (I'm using 2.3.1p112). Any pointers?

@dlo I don't use Rainforest to do CocoaPods dev. I just clone this repo, and if there are dependencies I need to modify, I update the CocoaPods Gemfile to use the :path arg to point to local checkouts of the other repos I need to modify

had the similar issue recently, the problem was that in one of the project targets "Use legacy swift version language" was set to "Unsupported 3.0 version", I changed it to "NO" and the issue resolved.
So it's a matter of project settings.

I'm having this issue as well, I've even manually set each framework in the workspace to Use legacy swift version language:NO, no luck. I've checked the podspecs for each dependency, I haven't seen any of them specifying SWIFT_VERSION as anything other than 3.0. Would love a more verbose error message here at least.

We always welcome PRs, and we especially appreciate ones that make error messages more clear! If someone would like to look into this, I think someone just needs to make a change in lib/cocoapods/installer/analyzer/target_inspector.rb inside the compute_swift_version_from_targets to include the targets with their Swift versions in the error message.

Opened up a PR to make this better.

could we get a 1.2.0.beta.2 version released? This would be very nice to have for testing. @DanToml

@zachlucas A 1.2.0.beta.2 will definitely be on its way out soon. For now, http://guides.cocoapods.org/using/a-gemfile can help you get setup running from master

Got here via Google. Answer for me was to search in the project.pbxproject for which I was building. Found one of these which was set to the wrong version:

SWIFT_VERSION = 3.0;

Setting it correctly got pod install to do its thing again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tlandsmancars picture tlandsmancars  路  3Comments

marzapower picture marzapower  路  3Comments

intelliot picture intelliot  路  3Comments

iosdev-republicofapps picture iosdev-republicofapps  路  3Comments

steffendsommer picture steffendsommer  路  3Comments