简体   繁体   中英

How to migrate a code from swift 3 to swift 4 or above?

I have just upgraded from xcode 10.1 to xcode 11.2.1. Now whenever I open my existing project in xcode 11.2.1 which was built in swift 3.0 it shows me " Unsupported Swift Version ".

Please anyone can give me a brief description about it.

这里我分享截图。

You cannot run swift 3 on Xcode 11. Download a version of XCode 10.1,You can run both.There will be option to migrate code to swift 4.

here you can download XCode 10.1:

XCode 10.1

Please check this link below. You can upgrade to swift 4.

https://medium.com/@hanif.awan2007/tips-upgrading-your-code-from-swift-3-to-swift-4-dbcba128b48b

You have a guide on official documentation: https://swift.org/migration-guide-swift4/

First check you build settings: 在此处输入图片说明

You have an option "Swift language version" change this to swift4.

Then, try to compile and fix your warns / errors. Most of them can be automatically fixed by xcode.

If you got some pod dependencies, update it.

Go to project navigator> Build Settings. search for swift Compiler - Language and change this to desired version. 在此处查看图片

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