Files
knowledge-kit/Chapter1 - iOS/1.58.md
2024-04-27 13:01:58 +08:00

20 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Swift 版本迁移问题总结
> 工程中存在一部分代码逻辑是 Swift 实现的,每次 Swift 版本升级、Xcode 版本升级或许意味着你需要对 Swfit 实现的这部分代码进行升级改动,此篇文章就记录 Swift 每次升级时踩过的坑
## Swift 5 && Xcode 10.2 的踩坑
1. 一部分改动是由于系统通知的名称改变造成的
| 改动前 | 改动后 |
|:--:|:--:|
| .UIKeyboardWillShow | UIResponder.keyboardWillShowNotification |
| UIAlertControllerStyle.alert | UIAlertController.Style.alert |
| UIAlertActionStyle.cancel | UIAlertAction.Style.alert |
| UIControlState.normal | UIControl.State.normal |
| UIEdgeInsetsMake(0, 20, 0, 20) | UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20) |
| XQNetworkingManager.jsonManager | XQNetworkingManager.useJSONSerializer |
| NSNotification.Name.UITextFieldTextDidChange | UITextField.textDidChangeNotification |
2. 当你修改完语法问题的时候,编译工程,发现还是存在一些问题。大体意思是说 Swift 的编译版本不再支持。所以我们需要选中 targets ,切换到 「Build Settings」 下面,搜索 「Swift Language Version」在后面勾选合适的 Swift 版本。在这里我选择了 Swift 5