Cocoapods: xcodebuild failing due to wrong Swift version use?

Created on 15 Sep 2016  路  5Comments  路  Source: CocoaPods/CocoaPods

What did you do?

I ran pod lib lint on the latest release of SwiftPriorityQueue (1.1.1). I have included a .swift_version file as specified by the latest CocoaPods release (1.1.0 RC2).

What did you expect to happen?

I expected my project to lint correctly because it builds fine in Xcode 8.

What happened instead?

It appeared to build against Swift 2.3 instead of Swift 3.0

David-Kopec:SwiftPriorityQueue dave$ pod lib lint

 -> SwiftPriorityQueue (1.1.1)
    - ERROR | xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
    - ERROR | xcodebuild:  /Users/dave/Documents/SwiftPriorityQueue/Sources/SwiftPriorityQueue.swift:40:5: error: expected declaration
    - ERROR | xcodebuild:  /Users/dave/Documents/SwiftPriorityQueue/Sources/SwiftPriorityQueue.swift:40:16: error: consecutive declarations on a line must be separated by ';'
    - WARN  | xcodebuild:  /Users/dave/Documents/SwiftPriorityQueue/Sources/SwiftPriorityQueue.swift:69:31: warning: extraneous '_' in parameter: 'element' has no keyword argument name
    - WARN  | xcodebuild:  /Users/dave/Documents/SwiftPriorityQueue/Sources/SwiftPriorityQueue.swift:94:33: warning: extraneous '_' in parameter: 'item' has no keyword argument name
    - WARN  | xcodebuild:  /Users/dave/Documents/SwiftPriorityQueue/Sources/SwiftPriorityQueue.swift:107:36: warning: extraneous '_' in parameter: 'item' has no keyword argument name
    - WARN  | xcodebuild:  /Users/dave/Documents/SwiftPriorityQueue/Sources/SwiftPriorityQueue.swift:133:32: warning: extraneous '_' in parameter: 'index' has no keyword argument name
    - WARN  | xcodebuild:  /Users/dave/Documents/SwiftPriorityQueue/Sources/SwiftPriorityQueue.swift:148:32: warning: extraneous '_' in parameter: 'index' has no keyword argument name
    - ERROR | xcodebuild:  /Users/dave/Documents/SwiftPriorityQueue/Sources/SwiftPriorityQueue.swift:95:24: error: value of type '[T]' has no member 'index'

[!] SwiftPriorityQueue did not pass validation, due to 4 errors and 5 warnings.

CocoaPods Environment

Stack

   CocoaPods : 1.1.0.rc.2
        Ruby : ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
    RubyGems : 2.0.14.1
        Host : Mac OS X 10.11.6 (15G1004)
       Xcode : 8.0 (8A218a)
         Git : git version 2.8.4 (Apple Git-73)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ d4aa4957329f39a05025d04d9d60969193c1c31a

Installation Source

Executable Path: /usr/local/bin/pod

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

Project that demonstrates the issue

https://github.com/davecom/SwiftPriorityQueue

Most helpful comment

I ran this

echo "3.0" >> .swift-version

Before doing pod lib lint. Is this not what you mean?

All 5 comments

You can define the swift version using the swiftenv format.

I ran this

echo "3.0" >> .swift-version

Before doing pod lib lint. Is this not what you mean?

My bad had .swift_version not .swift-version

This isn't working for me, please help

$ swiftenv versions
  3.0
  4.0.3
* 4.1 (set by /Users/Rex/Documents/projects/JSONValue/.swift-version)

$ swift --version
Apple Swift version 4.1 (swift-4.1-RELEASE)
Target: x86_64-apple-darwin17.4.0

$ pod lib lint

 -> JSONValueRX (4.0.1)
    - ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
    - ERROR | [iOS] xcodebuild:  /Users/Rex/Documents/projects/JSONValue/Sources/JSON.swift:238:31: error: value of type '[JSONValue]' has no member 'compactMap'

[!] JSONValueRX did not pass validation, due to 2 errors.
You can use the `--no-clean` option to inspect any issue.

$ cat .swift-version 
4.1

The error about compactMap, which was introduced in Swift 4.1, implies that it's using an older version of swift..

Ah, used --verbose. Seems like xcodebuild is the source of the issue

Building with `xcodebuild`. 
    $ /usr/bin/xcodebuild clean build -workspace /var/folders/p_/8vpjm7712vbf7nylknhvlnt00000gn/T/CocoaPods-Lint-20180511-50667-16egv4i-JSONValueRX/App.xcworkspace -scheme App
    -configuration Release CODE_SIGN_IDENTITY=- -sdk iphonesimulator -destination id=DAFE4621-CA40-4184-A485-E832076E0C7D

I'm guessing it's relying on Xcode 9.2's swift vs the package release I have installed. I'll download the new 9.3.1 release that just came out and see if that fixes things.

Was this page helpful?
0 / 5 - 0 ratings