JAL
JAL

Reputation: 42489

Migrating an iOS application using Cocoapods 1.0.1 from Swift 2.2 to 3.0

I'm currently upgrading an iOS app from Swift 2.2 to 3.0. I have pointed all of my pod dependencies to their Swift 3 versions and have migrated my code. However, when I run pod install and try to open my Workspace, Xcode still wants me to convert the "Pods" project to the latest Swift syntax:

The project "Pods" has targets that contain source code developed with an earlier version of Swift.

Convert to Current Swift Syntax

But I've already upgraded my dependencies to their Swift 3.0 versions. What gives?

(This is a canonical Q&A pair to help future users who encounter this issue)

Upvotes: 1

Views: 385

Answers (2)

Lloyd Roseblade
Lloyd Roseblade

Reputation: 121

I suggest using their release candidate version

sudo gem install cocoapods --pre

Then do a pod install again

Upvotes: 1

JAL
JAL

Reputation: 42489

I had this issue with Cocoapods 1.0.1 where I needed to manually specify the SWIFT_VERSION of the installed targets to be 3.0:

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

My complete Podfile (for a test/development pod):

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

Issue #5521 - Compiler Version for Xcode 8 helped find this workaround.

Upvotes: 3

Related Questions