XCode 8.2, does not detect that my project already is migrated to Swift 3

My whole project has been migrated to Swift 3, but Xcode still displays the following warning and error:


Warning:

"Swift 2.3 is deprecated and will be removed in a future release of Xcode. Migrate to Swift 3 now."


When I start the migration-wizard, all targets have the yellow triangle saying my project has already been migrated.


Error:

“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly."


All swift targets, including cocoapods written in swift, are using:

SWIFT_VERSION = 3.0


This same project worked flawlessly in XCode 8.1

Accepted Reply

Found work around. I went through each target in my project, toggled the "Use Legacy Swift Language Version" from "No" to "Yes" and back to "No" for each. The project then built again.

Replies

same here, went through all the project settings multiple times.... apple help please. Thanks

Found work around. I went through each target in my project, toggled the "Use Legacy Swift Language Version" from "No" to "Yes" and back to "No" for each. The project then built again.

thx - that worked :-)

Worked for me, too. Looking at problem project file, it had SWIFT=3.0.1 instead of 3.0. Editing that (all occurrences) fixed the problem as well. Will have to check repo to see when the bad value was set (8.1?).

you are correct, I did that too, I saw the 3.0.1 and I wasn't sure what had to go in there, so then toggling the setting to Yes and No fixed it... I hope Apple fixes this soon, it's unfortunate a basic setting like this is causing a project not to build.

Just to throw in that this worked for me as well and I'm using Carthage, not Cocoapods. This was such a terrible bug. Thanks for finding that workaround. I dug through every single one of my dependencies to find the issue and wasted almost an entire workday. Took less than 10 seconds to fix it with your workaround.

Thank you for calling this issue to our attention. I have filed two bugs to track this issue; you can reference them if you need to communicate with Apple in the future about this issue.

rdar://problem/29655623 tracks the fact that the migrator set SWIFT_VERSION "3.0.1" instead of "3.0"

rdar://problem/29655628 tracks the fact that a SWIFT_VERSION value of "3.0.1" erroniously triggers this warning.

Toggling Use Legacy to YES and then to NO resolved the error for me as well; I couldn't build. By the way, the issue started happening for me with Xcode 8.2 release.


Thanks!

Update on this issue:

– The bad "3.0.1" value for SWIFT_VERSION comes from a bug in Xcode 8.1. Xcode 8.2 will always set this correctly to "3.0".

– We are not able to reproduce the problem where a value of "3.0.1" triggers the "Swift 2.3 is deprecated and will be removed"... warning. In all cases we've seen of someone reporting this, there was at least one target in the workspace with a target that had a value of "2.3" (which shows up as Use Legacy Swift Version = YES in the build settings editor). If anyone has a reproducible case where they are certain that no targets in any projects visible in the workspace have a pre-3.0 value for SWIFT_VERSION, we'd appreciate a bug report at https://bugreport.apple.com.

– We _are_ able to reproduce the build error that is produced when SWIFT_VERSION is set to 3.0.1, and have all the information that we need to fix the problem.


For anyone just joining this thread, this problem can be worked around by toggling the "Use Legacy Swift Version" build setting to YES and back to NO for affected targets, or by editing your project files to fix all instances of SWIFT_VERSION = 3.0.1 to instead say SWIFT_VERSION = 3.0.

Thanks myusername001, that worked for me as well. 🙂

I think there also might be an issue with automatically migrating unit tests and UI-test targets. The test targets just don't show up in the migrator tool for me...


Mine were still at 2.3 even after running the migrator in 8.1, and the migrator in 8.2. This was not the reason my project failed to build though, that was the version 3.0.1 thing.