Can't convert to the latest version of Swift because can't find framework module

I have a small macOS application with an embedded framework, both written in Swift. Each has its own Xcode project in separate locations on my Mac, and I use an Xcode workspace to develop and build both at once. I do not use CocoaPods or Carthage. My application and framework build and run successfully.


When I try to convert to the latest version of Swift using the Xcode conversion command, it fails with a "no such module" error for the framework.

My online research shows that "no such module" errors have been plaguing developers who use embedded frameworks for several years. A dozen or more solutions have been suggested online, and they apparently work in some contexts but not in others. None of them work for me.


Has anybody successfully run the Xcode Swift conversion command with an embedded framework and everything written in Swift? If so, can you spell out the key setup features that made it work for you?

I finally solved the problem. For posterity, here's how I got it done:


• I temporarily copied the one swift code file in the framework project to the application project;

• I commented out all of the application code files' "import framework" directives;

• I switched to the new build system (File > Workspace Settings);

• I converted only the application project (I had already successfully converted the framework project);

• I turned off conversion of both test targets (I converted them separately, later, as noted below).


I then ran the Swift 4 converter, and it did not fail. It took a few moments to do its work, and then it showed me a comparison of the new Swift 4.0 code and the old Swift 3.2 code. I saved all the changes. When I then built the converted project, I had about two dozen compile errors that the converter was unable to fix. I manually changed three statements in my application code, and that resolved all of the errors. I then turned off @objc inference in build settings, as recommended, and building and running the application generated no @objc warnings or errors.


It turns out that the last step (turning off conversion of both test projects) was crucial. The two test targets were created by Xcode when I first created the application project, but I had not yet done anything with them. Even though they contained no code of mine, attempting to convert them to Swift 4 along with the application project is apparently what caused the dozens of Report navigator errors and the conversion failure. It was not enough just to uncheck the two test projects in the conversion dialog while I was starting the conversion. I had to turn them off first in the application scheme's Test settings.


I only tried turning off the two test projects in the application scheme's Test settings because I happened upon several email threads recommending this step in response to a different problem back in Swift 3 conversion days. It solved the Swift 4 conversion failure for me. To my surprise, I was nevertheless later able to turn both of the test projects back on in the Test scheme settings and convert both of them to Swift 4, one project at a time, which required no code changes because they are essentially empty.


I have now put the one framework code file back into the framework project and restored the import directives, and I am now back to developing my framework and application together in a single workspace in Swift 4.

Can't convert to the latest version of Swift because can't find framework module
 
 
Q