Steps to use Legacy Swift in Xcode 8

Xcode Swift iOS10

Xcode 8.0 is released with Swift 3 and Swift 2.3 compatibility.


If you already having a project with Swift 2.2 language support with Xcode 7.3.1 and you open the project in Xcode 8.0 then, you will be prompted for the migration assistant to do a migration pass. The assistant can also be invoked manually from the menu Edit -> Convert -> To Current Swift Syntax…

  • Use Swift 2.3 Modifies your project to enable the Use Legacy Swift build setting and provides source changes to be able to build against the new SDKs.
  • Use Swift 3 This is recommended. You will get source changes to be able to build your project using Swift 3 and take advantage of all the new features in Xcode 8.0.

If you want to work with new project and you want to work with Legacy code (Swift 2.3) or 3.0 then you can do settings from build settings as follows :

Build Settings - Swift Legacy Code
Build Settings – Swift Legacy Code

Default Setting is No (Swift 3). But if you want to do legacy code (Swift 2.3) then you have to select Yes (Swift 2.3).
Make sure you do this setting by starting of new project because many methods will change.
For Example :
Swift 3 Code
[code language=”obj-c”]
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
[/code]
Swift 2.3 Code
[code language=”obj-c”]
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
return true
}
[/code]
As per my opinion Swift 3 is recommended.
Happy Coding 🙂