简体   繁体   中英

How to define swift version of spec.dependency “xxx”, “~> 1.0” in podspec file

I am write a Cocoapod library, and I am using some dependencies.

Is it possible to specify the build version of Swift for a specific dependency?

Example:

Pod::Spec.new do |spec|
spec.name = "xxx"
spec.version = "0.0.1"
spec.swift_version = 5.0
...

spec.dependency "Alamofire", "~> 5.0"
spec.dependency "AnotherPod", "~> 1.1"
end

My package will be compiled with Swift 5, but my AnotherPod dependency needs to be compiled in Swift 4.2

I`m use Cocoapod 1.9.1

According to this document , there is no way to restrict dependencies to the certain swift_version .

You can monitor the dependency repositories when they change the swift version to the one that you don't support, let's say, in the version of Alamofire 5.1 they've upgraded swift_version , while you don't, - then you can limit the upper and lower allowed versions of your dependencies, like

spec.dependency "Alamofire", ['>= 5.0', '< 5.1']

You can refer to this document for advanced syntax of version limitation of dependencies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM