Swift编程Swift学习Swift

cocoapods建swift版本的私有库时注意的地方

2018-07-20  本文已影响14人  这个汤圆没有馅

Swift私有库步骤和OC私有库一样, pod lib create xxxx初始化时允许 include a demo application建立Example工程。我这边podspec文件里依赖了 SnapKit ,并 pod install

s.dependency 'SnapKit', '~> 4.0.0'

然而 pod lib lint 出现podspec验证不通过。这里的23个error都是跟 SnapKit 有关。

- WARN  | [DCCJAlertLoadingLib/DCCJAlert,DCCJAlertLoadingLib/DCCJLoading] swift: The validator used Swift 3.2 by default  because no Swift version was specified. To specify a Swift version during validation, add the `swift_version` attribute in your podspec. Note that usage of the `--swift-version` parameter or a `.swift-version` file is now deprecated.

- ERROR | [DCCJAlertLoadingLib/DCCJAlert,DCCJAlertLoadingLib/DCCJLoading] xcodebuild:  SnapKit/Source/ConstraintViewDSL.swift:86:63: error: argument labels '(rawValue:)' do not match any available overloads
- NOTE  | [DCCJAlertLoadingLib/DCCJAlert,DCCJAlertLoadingLib/DCCJLoading] xcodebuild:  SnapKit/Source/ConstraintViewDSL.swift:
86:63: note: overloads for 'LayoutPriority' exist with these partially matching parameter lists: (_bits: FPIEEE32), (from: Decoder), (S), (bitPattern: UInt32), (floatLiteral: Float), (_builtinIntegerLiteral: Int2048), (integerLiteral: Int64),(_builtinFloatLiteral: FPIEEE80), (exactly: T), (UInt8), (exactly: UInt8), (Int8), (exactly: Int8), (UInt16), (exactly: UInt16), (Int16), (exactly: Int16), (UInt32), (exactly: UInt32), (Int32), (exactly: Int32), (UInt64), (exactly: UInt64),(Int64), (exactly: Int64), (UInt), (exactly: UInt), (Int), (exactly: Int), (Float), (exactly: Float), (Double), (exactly: Double), (Float80), (exactly: Float80), (CGFloat), (NSNumber), (truncating: NSNumber), (exactly: NSNumber)

[!] DCCJAlertLoadingLib did not pass validation, due to 23 errors and 1 warning.
You can use the `--no-clean` option to inspect any issue.

1. cd进入Example的上层文件目录

2.创建 .swift-version 文件

touch .swift-version

3.设置swift版本号,根据当前xcode能支持的最高版本来

echo "4.1" > .swift-version

4.查看swift版本号

cat .swift-version
- ERROR | [DCCJAlertLoadingLib/DCCJAlert] xcodebuild:  /Users/tangyuan/Desktop/617/work/项目/永达/私有库/
DCCJAlertLoadingLib/DCCJAlertLoadingLib/Classes/DCCJAlert/CustomeAlertViewController.swift:337:13: error: value of 
type 'UIButton' has no member 'snp'

[!] DCCJAlertLoadingLib did not pass validation, due to 23 errors and 1 warning.
You can use the `--no-clean` option to inspect any issue.

这里报错就是SnapKit没有正确引入,只要cd Example进入工程,pod install后退到上层目录pod lib lint --allow-warnings即可。

总结: 建立swift版本私有库时,一定不要忘记添加.swift-version文件。如有表述不当的,欢迎指正。

上一篇 下一篇

猜你喜欢

热点阅读