14

I am getting this error trying to migrate to Swift 4.2 using the Xcode provided conversion tool. How do I fix it? The code builds fine otherwise.

enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
  • It was Swift 4.0 before. – Deepak Sharma Sep 19 '18 at 19:19
  • 3
    The project must compile in the current version without errors. @Hamish Swift 4.2 is not *source compatible with Swift 4.x*. There are a lot of constant name space changes. – vadian Sep 19 '18 at 19:19
  • Correct. I find that the first thing to do is compile, without converting. – matt Sep 19 '18 at 19:20
  • 1
    It compiles without converting. I had 4.0 Swift version selected before. However, manually changing Swift Language version to 4.2 starts the process of showing errors and possible fixes. – Deepak Sharma Sep 19 '18 at 19:28
  • @Hamish I converted my entire project library to Swift 4.2 (about 20 projects). There were two CLI projects without changes. Everything else wasn't source compatible. – vadian Sep 19 '18 at 19:30
  • @DeepakSharma Note that once you have tried and failed in this way, you will be hosed until you quit, delete derived data, and then reopen and manually set all targets back to Swift 4 (or whatever they were previously). – matt Sep 19 '18 at 19:37
  • You mean I should back off to Swift 4.0? – Deepak Sharma Sep 19 '18 at 19:38
  • There are bugs in Swift 4.2/iOS SDK. Do you advice to keep using Swift 4.0? There were 166 errors and I am resolving one by one – Deepak Sharma Sep 19 '18 at 19:40
  • @DeepakSharma Most likely you caused the ***bug*** by ***manually** changing Swift Language version to 4.2*. Don't do things manually unless you know what you're doing. No offense. – vadian Sep 19 '18 at 19:50
  • The bug was before changing the Language to version 4.2. I have to do thinks manually. – Deepak Sharma Sep 20 '18 at 07:05
  • 3
    I manually compiled resolved all 166 errors, it works! – Deepak Sharma Sep 20 '18 at 11:31
  • 1
    I had some issues in the test target, and that was the issue for me, despite not having selected the test target for converting into 4.2. Once fixed the test issues, I have been able to use the automatic conversion tool – Valerio Sep 20 '18 at 12:24
  • pod update may help you – gEeKyMiNd Sep 24 '18 at 11:57

5 Answers5

3

Do you have any libraries in your project? I think you are trying to covert your project with dependencies and there are problems in them with new swift version. Try to uncheck all dependencies except your project and convert to new version of Swift

Barbatosso
  • 77
  • 8
1

I had similar problem, solved it by

1- Change swift lang version in build setting of all app and test targets to 4.2

2- build app, errors will happen like UIControlState renamed to UIControl.state

3- fix all of the build errors

4- I updated all recommended settings by xcode

5- then I asked xcode to convert to swift4.2

updated all recommended settings

Community
  • 1
  • 1
Mohamed DiaaEldin
  • 1,061
  • 1
  • 10
  • 23
0

It's always a good idea to upgrade all dependencies (e.g. via Cocoapods) to its latest version that support Swift 4.2. In my case, I also need to manually change the Swift Language Version build settings for a pod library from Swift 4 to Swift 4.2 as that lib uses some APIs in 4.2 only.

BabyPanda
  • 1,562
  • 12
  • 18
0

I have problem too. I find solution to fix this problem in web https://ericasadun.com/2018/09/13/converting-projects-by-hand-to-4-2/

First

You try delete pod in pod file and install pod again and pod update in your folder project in command then conversion to Swift 4.2. if it's not work do this in second.

Second

you try follow do this picture in build setting project or try follow do in link web.

enter image description here

enter image description here

Community
  • 1
  • 1
Papon Smc
  • 576
  • 4
  • 11
0

As described here,

There may have been issues with processing the targets that will negatively impact the migration process. Switch to the Report Navigator and select the Convert entry that was added; this is the conversion build log. Check the log for errors that may have showed up.

If you see errors about not being able to code-sign the target, try disabling code-signing from the build settings of the target. If you see other errors, please file a bug report and include the details. You are strongly encouraged to attach a project that illustrates the faulty migration if possible.

Mohit Singh
  • 1,452
  • 1
  • 18
  • 27