Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift 3 CocoaPod does not pass lint

I’m upgrading a CocoaPod to Swift 3. It compiles and runs just fine, but pod lib lint fails with numerous compiler errors, because the linter tries to compile everything as Swift 2.3.

Attempts to set SWIFT_VERSION in the podspec or change “Use Legacy Swift Language Version” in my framework’s Xcode project do not solve the issue.

How do I make the pod linter use Swift 3?

like image 494
Paul Cantrell Avatar asked Sep 15 '16 21:09

Paul Cantrell


3 Answers

First you have to update cocoapods to 1.1.0.rc.2 by

[sudo] gem install cocoapods --pre 

then as Paul Cantrell says, do

echo 3.0 > .swift-version

in the same dir where the pod spec is

like image 27
R0CKSTAR Avatar answered Nov 13 '22 10:11

R0CKSTAR


It turns out CocoaPods now looks for a .swift-version file, as of 1.1.0.rc.2 (changelog). If the file contains 3.0, linting will work:

echo 3.0 > .swift-version
like image 105
Paul Cantrell Avatar answered Nov 13 '22 09:11

Paul Cantrell


I have this issue when develop SDK which is depending on socket.io-Client-Swift. After type

echo 3.0 > .swift-version

still don't fix my problem.

However, I noticed pod lint use xcodebuild to test whether the framework is ready to be release without error. Make sure you use Xcode8 to build pod lint. For some reason, I install both Xcode7 & Xcode8 and changed my xcodebuild path to xcode7, so the lint won't be pass when I want to make a framework with swift 3.

use the following code to make sure your xcode setting is right.

xcode-select -print-path

if the xcode-select path is not point to xcode8, you should using

xcode-select -switch <path>

set the xcode-select path to xcode8 which is usually in your Applications.

like image 22
Jerome Li Avatar answered Nov 13 '22 11:11

Jerome Li