简体   繁体   English

将xcode项目从swift 3降级到swift 2.2

[英]Downgrade xcode project from swift 3 to swift 2.2

I downloaded the new xCode 8 beta. 我下载了新的xCode 8 beta。 When i opened my old project(in swift 2.2), i clicked the convert to new swift syntax, and i clicked swift 3. The problem is that i use a framework downloaded with carthage (Kanna). 当我打开我的旧项目(在swift 2.2中)时,我点击了转换为新的swift语法,然后我点击了swift 3.问题是我使用了与carthage(Kanna)下载的框架。 I have tried to use the: 我试过用:

carthage update 迦太基更新

but it doesn't work. 但它不起作用。

When i try to run the code on the new Xcode-beta, i get this error: 当我尝试在新的Xcode-beta上运行代码时,我收到此错误:

Module file was created by an older version of the compiler; 模块文件由较旧版本的编译器创建; rebuild 'Kanna' and try again: 重建'Kanna'并再试一次:

First of all save a backup of your current project. 首先保存当前项目的备份。 Now! 现在!

Solution 1 解决方案1

Open your project with Xcode 7.3.1, it uses Swift 2.2 so it will signal you a bunch of errors. 使用Xcode 7.3.1打开您的项目,它使用Swift 2.2,因此它会向您发出一堆错误信号。 Since you know Swift 2.2 you should be able to fix the errors and make you project again compatible with Swift 2.2 既然您了解Swift 2.2,那么您应该能够修复错误,并使您的项目再次与Swift 2.2兼容

Solution 2 解决方案2

In Xcode 8 beta you can choose the Swift versione (Swift 2.3 or Swift 3.0). 在Xcode 8 beta中,您可以选择Swift版本(Swift 2.3或Swift 3.0)。 Select Swift 2.3 (it's fully compatible with Swift 2.3 but does support the new iOS API). 选择Swift 2.3(它与Swift 2.3完全兼容,但支持新的iOS API)。 Then, again, fix the errors manually. 然后,再次手动修复错误。

Solution 3 解决方案3

Open the library you are using and use Xcode 8 to upgrade that to Swift 3.0. 打开您正在使用的库,并使用Xcode 8将其升级到Swift 3.0。 This is a temporary solution until the developer of that library will provide the upgraded code 这是一个临时解决方案,直到该库的开发人员将提供升级的代码

When you open your project with Xcode 8.0 for the first time, you will be prompted via the migration assistant to do a migration pass. 当您第一次使用Xcode 8.0打开项目时,将通过迁移助手提示您执行迁移过程。 The assistant can also be invoked manually from the menu 也可以从菜单中手动调用助手

Edit -> Convert -> To Current Swift Syntax…

If you upgraded code eg 2.3 to 3.0 and now want downgrade to 2.3 you can use above. 如果你升级了代码,例如2.3到3.0,现在想要降级到2.3,你可以使用上面的代码。 If any errors occur copy your code from last commit in your repository and it should work fine. 如果发生任何错误,请复制您的存储库中最后一次提交的代码,它应该可以正常工作。

Seems like i am very late to answer but there is update available for 'Kanna' framework supporting swift 3.0. 好像我很晚才回答,但有关于支持swift 3.0的'Kanna'框架的更新。 You can add this to your podfile if you use CocoaPods 如果使用CocoaPods,可以将其添加到podfile中

use_frameworks!
pod 'Kanna', '~> 2.0.0'

Or for Carthage you can install like 或者对于迦太基你可以安装像

github "tid-kijyun/Kanna" ~> 2.0.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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