@import X; Causes of error Failed to create module X

I have a TSUI user interface defined as a module. It has both Objective-C and Swift code. If I import it into Objective-C code as follows:

#import <TSUI/TSUI.h> 

Everything works fine, but then I only get access to the Objective-C code. However, if I import it as:

 @import TSUI; 

or

 #import <TSUI/TSUI.h> #import <TSUI/TSUI-Swift.h> 

Everything compiles fine, but in Xcode I get the following error: enter image description here

Both in the structure and in the application code, I set the following assembly parameters:

  • Inline content contains code Swift = YES
  • Allow non-modular inclusion in structural modules = YES
  • Enable Modules = YES

I tried to clear the project by clearing the derived data and the problem keeps coming back. It also appears if the framework does not contain Swift code, but is included in @import instead of #import. At the moment, I think this is a mistake.

+5
source share
2 answers

Delete current import statements so the project is compiled.

Create your own project.

Try importing again.

0
source

There is something wrong with your module. I believe in your TSUI project, you need to install the modulemap file. You should have a file that simply imports all the files that you would like to include in the module. You can call it TSUI-umbrella.h. In your modular map, you should set this as your umbrella header. Then, when you run @import (which imports the module), you will get the correct compilation. Alternatively, you can do

 #import <TSUI/TSUI-umbrella.h> 

or basically

 #import <ModuleName/UmbrellaHeader> 
0
source

Source: https://habr.com/ru/post/1244833/


All Articles