Cocoapods: Can't install pod with Xcode 8/Swift 3/Cocoapods 1.1.0 RC2

Created on 14 Sep 2016  ·  47Comments  ·  Source: CocoaPods/CocoaPods

What did you do?

/usr/local/bin/pod install

What did you expect to happen?

Install all pod dependencies correctly.

What happened instead?

The install failed and no workspace is created.

CocoaPods Environment

Stack

   CocoaPods : 1.1.0.rc.2
        Ruby : ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
    RubyGems : 2.5.1
        Host : Mac OS X 10.11.6 (15G1004)
       Xcode : 8.0 (8A218a)
         Git : git version 2.6.4
Ruby lib dir : /usr/local/Cellar/ruby/2.3.0/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 90c40f1bd8fb3738b8e1b725c3ffe9ac284ac9bb

Plugins

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

Podfile

platform :ios, '9.0'

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

def shared_pods
  pod 'PromiseKit', '~> 4'
end

target 'AwaitKitExample' do
  shared_pods
end

target 'AwaitKitTests' do
  shared_pods
end

Error

Errno::EEXIST - File exists @ dir_s_mkdir - /Users/yannickloriot/Development/perso/AwaitKit/Example/Pods/Target Support Files/PromiseKit
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb:92:in `mkdir'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb:92:in `mkdir'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb:92:in `create_support_files_dir'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb:21:in `block in install!'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/user_interface.rb:142:in `message'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb:19:in `install!'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer/xcode/pods_project_generator.rb:155:in `block (2 levels) in install_libraries'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer/xcode/pods_project_generator.rb:153:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer/xcode/pods_project_generator.rb:153:in `block in install_libraries'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/user_interface.rb:142:in `message'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer/xcode/pods_project_generator.rb:152:in `install_libraries'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer/xcode/pods_project_generator.rb:64:in `generate!'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer.rb:179:in `block in generate_pods_project'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/user_interface.rb:64:in `section'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer.rb:178:in `generate_pods_project'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/installer.rb:115:in `install!'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/command/install.rb:37:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/claide-1.0.0/lib/claide/command.rb:334:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/lib/cocoapods/command.rb:50:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-1.1.0.rc.2/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

Project that demonstrates the issue

AwaitKit example in the swift3 branch: https://github.com/yannickl/AwaitKit/tree/swift3/Example

awaiting input

Most helpful comment

@andrew8712 Sorry about that! - If you run that in Terminal, before running pod spec lint or pod trunk push, it will create a .swift-version file that will be used by CocoaPods to determine which Swift version we should give Xcode.

All 47 comments

Got the same. 👍

I'm having the same issue

Fixed by setting Use Legacy Swift Language Version build setting to No for each target.

It does not work for me. Or I missing something...

Ah yes sorry, it works now. @andrew8712 thank you for the hint!

@andrew8712 Was this for the project targets, or the CocoaPods targets?

@andrew8712 @yannickl @Katafalkas could one of you try my branch. It should provide a nicer error that points out the targets that have mismatched Swift versions:

gem 'cocoapods', :git => 'https://github.com/benasher44/CocoaPods', :ref => '141ab0bf7b10cfef4f07fe3312574fdf380864c5'

You'd have to try it before you applied the fix.

Updated with a new sha, since the previous one would always raise an error. Whoops!

@DanToml, it was probably for project targets, as I had the same issue and solution today (#5834).

@Coeur would appreciate if you could try out the branch as well 😃

@DanToml yes the target project needs to use the same SWIFT_VERSION (here the 3.0).

@benasher44 you meant https://github.com/benasher44/CocoaPods, not https://github.com/CocoaPods/benasher44, right?

The output is:

$ bundle exec pod install
Analyzing dependencies
[!] The following pods are integrated into targets that do not have the same Swift version:

Backendless-ios-SDK required by 37degrees (Swift 3.0), 310 K (Swift ), 37degreesTests (Swift 3.0), 37degreesUITests (Swift 3.0)
DCKit required by 37degrees (Swift 3.0), 310 K (Swift ), 37degreesTests (Swift 3.0), 37degreesUITests (Swift 3.0)
EAIntroView required by 37degrees (Swift 3.0), 310 K (Swift ), 37degreesTests (Swift 3.0), 37degreesUITests (Swift 3.0)
EARestrictedScrollView required by 37degrees (Swift 3.0), 310 K (Swift ), 37degreesTests (Swift 3.0), 37degreesUITests (Swift 3.0)
KVNProgress required by 37degrees (Swift 3.0), 310 K (Swift ), 37degreesTests (Swift 3.0), 37degreesUITests (Swift 3.0)
TPKeyboardAvoiding required by 37degrees (Swift 3.0), 310 K (Swift ), 37degreesTests (Swift 3.0), 37degreesUITests (Swift 3.0)

Is 310 K an objective-c only target?

@orta No, Swift target, which has Use Legacy Swift Language Version = Unspecified.

@andrew8712 ha! Updated! Good catch

@DanToml seems like there's something up with how we're handling pod variants in this case?

Maybe we should make unspecified compatible with any pod swift version as long as all of the pod swift versions are the same?

It should be better to check that all pods fit the target project swift version (with Xcode 8), if not, it prints an error to the user explaining why it fails:

  • Target project have no SWIFT_VERSION specified

or

  • Pod x and y are not compatible with SWIFT_VERSION

@benasher44 Yeah that's my guess too

@benasher44 @DanToml @orta I also noticed that pod lib lint and pod trunk push are generating targets with Use Legacy Swift Language Version set to Yes, though my library is migrated to Swift 3. This causing xcodebuild to fail.

@andrew8712 If you echo "3.0" > .swift-version and try again, then it should work

@DanToml Thanks for the tip. I'm not very proficient in this stuff, where should I put this line?

@andrew8712 Sorry about that! - If you run that in Terminal, before running pod spec lint or pod trunk push, it will create a .swift-version file that will be used by CocoaPods to determine which Swift version we should give Xcode.

@DanToml Thank you very much, that worked!

@DanToml running echo "3.0" > .swift-version does allow to do pod spec lint and pod trunk push. It took me a while to get to this thread, maybe this can be posted somewhere on the cocoapods website or stackoverflow until it is the issue is resolved?

It's going to be in the official blog post for when 1.1.0 is released 👍

Ok. Great.

@orta I pushed my Swift 3 code. But when I try to run and Objective C based project after pod install it does not build.
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.

I tried echo "3.0" > .swift-version with install and update, but it didn't help

Fixed by setting Use Legacy Swift Language Version build setting to No for each target.
Is there a way to automate this when installing the pod?

I have some issues to with my project, my pod file is following:

project 'MyApp'
workspace 'MyApp'

# Uncomment this line to define a global platform for your project
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '9.0'
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

target :MyApp do
  # Comment this line if you're not using Swift and don't want to use dynamic frameworks

   #pod 'Google/Analytics'
   pod 'Fabric'
   pod 'Crashlytics'
   pod 'SnapKit'

end

target 'IDCommonNeedsSwift' do

    pod 'SnapKit'
    project '../iCommonNeeds/IDCommonNeedsSwift/IDCommonNeedsSwift.xcodeproj'

end

post_install do |installer| 
  installer.pods_project.targets.each  do |target| 
      target.build_configurations.each  do |config| config.build_settings['SWIFT_VERSION'] = '3.0' 
      end 
   end 
end

I want to use SnapKit in MyApp and in IDCommonNeedsSwift. But when i want to build says that there is no snp on a view, but it can import SnapKit without any problems.

I have An WorkSpec structure as following

WorkSpace
|
------> MyApp with and iOS target with the same name
|
------> IDCommonNeedsSwiftwith and iOS target with the same name

@andrew8712 's one weird trick worked for me

Hi guys I just had this problem with a framework target project consisting only of objective c files, because it was using a pod made with swift. There's no build setting to define the swift version because there's no swift files in the project yet. Had to add an empty swift file to the project so that it would appear and I could set it to not use legacy... lols

@KieranHarper Some of the replies above kind of mention that in that case, you can add a "User-Defined" setting to your build settings named "SWIFT_VERSION" with the value of "3.0". That will prevent you from having to add a swift file just to set the setting. You may or may not have to do that to all the pods projects too like @kimdv has at the end of his podfile.

My problem still continues. I tried all the solutions but they can't work. I can't install any Swift 3 updated libraries. e.g. Toast-Swift released a new version 2.0.0 which is compatible with Swift 3 but I can't install the 2.0.0, I can install only version 2.3.0 which is compatible with Swift 2.3. Same problem still continues all of the framework's new Swift 3 compatible version on master branches. It says that

[!] Unable to satisfy the following requirements:

  • Toast-Swift (~> 2.0.0) required by Podfile

None of your spec sources contain a spec satisfying the dependency: Toast-Swift (~> 2.0.0).

You have either:

  • out-of-date source repos which you can update with pod repo update.
  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

Note: as of CocoaPods 1.0, pod repo update does not happen on pod install by default.

but I have already cleaned and update (pod repo update) the cocoapods caches and installed new new beta version of cocoapods, but problem still continues. I have also tried the echo "3.0" >> .swift-version command of course.

Here is my podfile:

platform :ios, '9.0'

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

target 'testswift3' do

pod 'Toast-Swift', '~> 2.0.0'

end

@DavidSchechter how do you find the generated cocoapod project to change its settings?

It happens also with Swift 2.3 projects.

I can also confirm this seems to happen with swift 2.3 and 3. Haven't found a workaround yet.

What is the ETR for this issue? I was told this would be fixed by last weekend 9/25. This has delayed my project because my Developer cannot compile his code.

@mercedg as a workaround you can you this in Podfile https://github.com/krzyzanowskim/CryptoSwift/issues/342#issuecomment-249851530 or set it manually for targets

For love or money I couldn't get anything to work. As I'm in Xcode 8 with Swift 3, I had to add a few repositories via git submodule manually.

If any of you is using post_install to set the swift version, don't forget to do pod deintegrate before pod install.

And if everything fails, then just provide a public sample of your project: you could for instance delete all {.h,.m,.swift,.xib,.storyboard,.xcasset} except a minimal AppDelegate, xcodeproj and Podfile.

@ttuygun You can solve this problem by using:
pod 'Toast-Swift', :git => 'https://github.com/scalessec/Toast-Swift.git', :branch => 'master'

@ttuygun, andytriboletti is correct, latest version of Toast-Swift podspec on Github is 2.0.0, but latest version of podspec on CocoaPods is 1.4.0, so currently you need to set the path of the desired branch or tag manually. See https://github.com/scalessec/Toast-Swift/issues/38

@DanToml hi. I did create a .swift_version and update CocoaPods to 1.1.0. That works when I use pod lib lint (thank you for that), but I got an error when I use pod trunk push:

[!] The Pod Specification did not pass validation.
The following validation failed:
- Warnings: Unrecognized `pushed_with_swift_version` key.

Do you have any idea?

I'm experiencing the same issue as @Meniny on my pod spec: I'm trying to publish NetUtils v3.0.0. pod spec lint works, but pod trunk push gives:

> $ pod trunk push                                                                                                                            [±master ✓]

[!] Found podspec `NetUtils.podspec.json`
Updating spec repo `master`
Validating podspec
 -> NetUtils (3.0.0)

[!] The Pod Specification did not pass validation.
The following validation failed:
- Warnings: Unrecognized `pushed_with_swift_version` key.

Not knowing what to do, I added the .swift-version file and even pushed that to github, but that didn't help. Hoping for a quick solution...

Quick follow-up: I published anyway using:

pod trunk push --allow-warnings

@svdo thx.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hmistry picture hmistry  ·  3Comments

marzapower picture marzapower  ·  3Comments

pallaviMN picture pallaviMN  ·  3Comments

steffendsommer picture steffendsommer  ·  3Comments

iosdev-republicofapps picture iosdev-republicofapps  ·  3Comments