Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update to Xcode 9 and Swift 4

I'm kinda new to Swift (less than 1 full year), and I'm not sure how to update to latest Swift within the new Xcode each year. My project has been started under Xcode 8 and Swift 3.2. Now I upgraded Xcode 9, which AFAIU supports Swift 4.

Since I'm using Cocoapods, I obviously updated all pods to their latest versions, which I believe is correct behavior.

However, I see that the Swift version in target settings is still set to Swift 3.2. What exactly does that mean? Should I change it to Swift 4 instead? Or that's just like minimum version that I have to write code according to?

Also, I have 2 warnings in the project:

enter image description here

Regardings Pods, it is clear that Cocoapods will fix that, so np.

What about my Workspace? My target builds fine without errors and warnings, I'm not sure why it tells me about conversion? Shouldn't it tell an exact line in the file with code instead?

Please, describe what is the correct flow of update to latest Swift in general, and how this works with some of pods that are not updating to the latest Swift each year. Will I be forced to remove them, or like fork and update to latest Swift manually?

like image 665
Stas Ivanov Avatar asked Oct 18 '17 10:10

Stas Ivanov


People also ask

Does Xcode 11 support ios8?

Xcode 11 supports development for devices running iOS 13.1. Xcode 11 supports on-device debugging for iOS 8 and later, tvOS 9 and later, and watchOS 2 and later.

How do I update my Apple Xcode?

Downloading and updating Xcode The current release of Xcode is available as a free download from the Mac App Store. The Mac App Store will notify you when an update is available or you can have macOS update automatically as it becomes available.

Does Xcode 13.3 Work on Big Sur?

Xcode 13 is compatible with macOS Big Sur 11.3 or later.


1 Answers

Upgrading Xcode version, will not change/upgrade your Swift programming language version. These warning show, your current Swift programming language version is not 4.0 (it is below 4.0 i.e. 3.2).

(Also note, Xcode 9 and 8.3 both support Swift 3.2. You can work with Xcode 9 using Swift 3.2 also.)

So, if you open your Xcode 8.x project in Xcode 9, will work with Swift version 3.2.

Manually you need to change Swift 3.2 to 4.0 from project build settings.

Here is - How to see current Swift language version and change it to newer.

enter image description here

Also note: Once you change your swift language ensure following steps:

  • You must update/upgrade your cocoa pod (CocoaPods)
  • Update your project's pod libs/files (using command pod install or pod update)

For easier migration refer these answers:

  • Xcode 9 Swift Language Version (SWIFT_VERSION)

(Xcode) Menus: Edit ► Covert ► To Current Swift Syntax

enter image description here

like image 158
Krunal Avatar answered Oct 08 '22 23:10

Krunal