New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler Version for Xcode 8 #5521

Closed
opswhisperer opened this Issue Jun 15, 2016 · 6 comments

Comments

Projects
None yet
6 participants
@opswhisperer
Copy link

opswhisperer commented Jun 15, 2016

Report

What did you do?

Run pod install for a pod that uses swift 2.3

What did you expect to happen?

Install all pod dependencies correctly.

What happened instead?

The pod is installed but the compiler version setting is not respected and Xcode 8 defaults for Swift 3

CocoaPods Environment

Stack

   CocoaPods : 1.0.1
        Ruby : ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
    RubyGems : 2.0.14.1
        Host : Mac OS X 10.12 (16A201w)
       Xcode : 7.3.1 (7D1014)
         Git : git version 2.7.4 (Apple Git-66)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ fdeab0150c4f811dc33db08c74e66cb75b54697e

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

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

Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '9.0'

use_frameworks!
target 'Concert Playlist' do
pod 'Onboard'
pod 'Localytics'
pod 'BuddyBuildSDK'
pod 'Doorbell'
pod 'Google/Analytics'
pod "LaunchKit"
pod "Branch"
pod 'Charts', :git => "https://github.com/opswhisperer/Charts.git", :branch => "xcode8_swift23"
pod "AFNetworking"
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
pod 'iRate'
pod 'GoogleConversionTracking'
pod 'UIBarButtonItem-Badge', :git => "https://github.com/mikeMTOL/UIBarButtonItem-Badge.git"
pod 'GoogleIDFASupport'
end

This project is using swift 2.3, if you install it, Xcode does not set the compiler version
pod 'Charts', :git => "https://github.com/opswhisperer/Charts.git", :branch => "xcode8_swift23"

@opswhisperer

This comment has been minimized.

Copy link

opswhisperer commented Jun 15, 2016

As a work around I did this

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

But it really should preserve whatever is in the framework if it is set

@neonichu

This comment has been minimized.

Copy link
Member

neonichu commented Jun 16, 2016

I think we should generate the build setting with 2.3 by default and tell folks to use a post_install hook if they want to use 3.0 — possibly inferring from the app could also be a sensible thing to do before applying the default.

I don't think that it is feasible to add this to the podspec as there is no clear definition on what e.g. Swift 3.0 is until the stable version ships. So there really isn't a way for CP to determine if a certain Pod would actually build with whatever Swift version is currently being used.

@jshier

This comment has been minimized.

Copy link

jshier commented Jun 20, 2016

@neonichu I'm not sure what this means: there is no clear definition on what e.g. Swift 3.0 is until the stable version ships. Isn't that rather irrelevant to CocoaPods? It just means whatever the Xcode 8 beta currently installed says it means. Ultimately, I guess I don't understand the reasoning for not exposing this setting in the podspec, as Xcode 8 will support both, and for at least the next year it's an official setting supported by Apple. Forcing users to use a post_install hook to set it one way or the other doesn't seem like a good long term solution.

@orta

This comment has been minimized.

Copy link
Member

orta commented Jun 20, 2016

There is currently a PR pulling the version from the targets - #5540

@tomaskraina

This comment has been minimized.

Copy link

tomaskraina commented Sep 23, 2016

Hey guys, which version of Cocoapods do I need in order to not use this workaround - #5521 (comment)? Is it specified/documented anywhere?

I'm still getting “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." errors for pods.

bundle exec pod --version
1.0.1
@JALsnipe

This comment has been minimized.

Copy link

JALsnipe commented Sep 28, 2016

@tomaskraina That workaround is working for me with Cocoapods 1.0.1. My Podfile:

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

use_frameworks!

target 'MyApp' do
  pod "MyPod", :path => "../"
end

target 'MyApp_Tests' do
  pod "MyPod", :path => "../"  
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment