Convert to Swift's current syntax - “No such module” (Swift 4, Xcode 9)

In Xcode 9, I am trying to do an automatic conversion to Swift 4. It crashes with the following message:

enter image description here

Error navigating to current Swift syntax
Before attempting to migrate, make sure that all selected targets successfully worked with the current version of Swift.

He complains about the missing module. But when I do regular assembly, there are no problems. I'm not sure if this is relevant, but the module (which is not available in Xcode) has already been converted to Swift 4 earlier (it has its own project).

Note: Cocoapods / Carthage are not used here.

Note. Two solutions have tried (and worked), but do not address the underlying problem.

  • One solution is to do the conversion manually (change the Swift version to 4 in the build setup and apply Fix-Its one at a time until there are no more build errors).
  • Another solution is to disable the third-party structure (comment out all the code where it was used), perform automatic migration, and then turn on the framework again. It can get quite complicated with large projects.
+10
ios xcode swift swift4 xcode9
source share
5 answers

I can’t find a solution yet.

Now I am fixing the Swift Language Version setting

enter image description here

After changing from 3.2 to 4.0, I compile and fix errors and warnings manually.
I am waiting for a better solution!

+8
source share

I also had a problem converting my project to Swift 4.0. It seems that the problem occurs when trying to convert a target that imports a framework that is already in Swift 4.0. In the screenshot, you are trying to convert "RecipeTextParser", which imports "SovaTools", which is already Swift 4.0.

I found a dirty but working solution. When converting, you can use the older (Swift 3.2) version of "SovaTools". You must NOT check its mark in the target selection window of the conversion tool. Then, when the "RecipeTextParser" is successfully converted, you can again use the Swift 4.0 version of "SovaTools".

+5
source share

I got this error, and in my case, one of my Pods (one Xcode complained) was the target of Swift 4, and the rest were Swift 3.2. Looking at the build logs, it looks like Xcode built this infrastructure in one place and looked for it in another. When I reverted this Pod to an older version (using Swift3.2), the problem disappeared. Obviously, Xcode error. Hth

+4
source share

The Xcode language migration function (Xcode 9) is not so accurate that it can transfer your complete code / project from one fast version to another with zero tolerance. It skips a bit of code migration for us (developers). This may be a mistake or inaccuracy of the tool. But you also need to make some effort manually to fully migrate the fast language version for your project / code.

Now, according to your picture, Xcode is displayed and the error for the "RecipeTextParser" frame. I think this is an external / external structure. One more note: you integrated this infrastructure with CocoaPods:

Any of the following reasons may result in denial of code migration:

  • CocoaPods blocks the framework (files) for editing. Thus, the language migration process cannot transfer (or identify) code for an external / third party.
  • In general terms, Framework is a package of code files, so the framework itself may not allow editing of the file / source code.

Offer as a solution:

  • Update your cocoa modules, as well as all the frameworks integrated with cocoa modules compatible with the latest version of the fast version.
  • If you manually integrated / added external / third-party frameworks, you also need to update and replace them.

It takes some manual effort to completely migrate code between fast languages. I tried fast migration with the options above, and all my projects are now compatible with fast 4.

+1
source share

Just upgrade your module and this will solve the problem.

To update a module:

  • open a terminal and go to your project directory
  • pod type update

This solved my problem.

0
source share

All Articles