关于Xcode 9的一些坑

Snakit

更新了Xcode 9 以后,Snapkit就出了一些问题,报了10几个error。
Github看了以后,作者给出了[NOTICE] Xcode 9 Compatibility with CocoaPods

Currently Cocoapods is not able to correctly mix Swift 3.2 and Swift 4.0 pods. SnapKit 4.0.0 is only compatible with Swift 4.0.0, if you have integration issues use SnapKit 3.2.0 as there is no functional difference between the two.
In a future release of SnapKit 4.x.0 we may bring compatibility with Swift 3.2.0 if Cocoapods continues to have issues.

大致意思是说cocoapods不能同时兼容Swift 3.2和Swift 4.0,若使用Swift 3.2就使用Snapkit 3.2.0,若使用Swift 4.0就使用Snapkit 4.0.0,这样就可以正常使用了。

Swift 4.0

@objc

Swift 4.0 需要把project和target的Swift 3.0 @objc Inference设置为Default。如图:

设置

当使用OC相关的方法时,就要自己添加@objc,并且,如果使用KVC,所有的属性前面都要加@objc

subString

Swift 4.0弃用了subString,采用String.index来获取索引,然后使用范围来获取子串。例如:

/**
 * String[]的方式获取的子串的类型为String.Subsequence,若要使用,
   需要转换为String
 * index方法有index(after),index(of),index(before)
 * ...表示直到末尾
 * ..<表示不包括最后一个字符
 */
let query = "code=12345678"
// 获取=后面的字符的索引
let start = query.index(after: query.index(of: "=")!)
// 从start索引开始一直到结束
let code = query[start...]
// code的结果为12345678

以上是我更新遇到的一些问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值