0
votes

Because of a constraining library, I need to use Objective-C files in my Swift project.
So, I added the import module-Swift.h in my .m file.
It finds it without any issues.
The problem come from the auto-generated module-Swift.h" file.
I have a lot of errors, mainly from classes and protocols coming from Pods.
Image

Image

Image

Is there any config to fix this issue ?

2
are u added #import <MessageUI/MessageUI.h> thisKavitha Madhu
Hi, thank you for your answer. Where should I add this line ? In the objective-C file that use my Swift functions ?Anas A.
Before that u create a bridging header ,below is my answer and add this #import <MessageUI/MessageUI.h> #import <MessageUI/MFMailComposeViewController.h> in that header file.Kavitha Madhu

2 Answers

2
votes

If you want to use objective c files in swift project, bridge the Objective files.

1)Create a new header file and name it like "your project name-Bridging-Header.h". The file must be saved to your project folder

2)Select your xcode project -> select your build target -> select build settings -> click the "all" option at the top -> search for Swift Compiler - General

3)Select Objective-C Bridging Header and give the path as $(PROJECT_DIR)/$(PROJECT_NAME)/$(PROJECT_NAME)-Bridging-Header.h

4)Finally add your objective files into the header file.

1
votes

Thanks to Kavitha Madhu, I found the solution !

For those who encounter the same issue:

If you want to use Swift classes and functions in you Objective-C code.
But, some of you Swift functions use Pods protocols and delegates.
You need to add in your Objective-C code the import of the pods headers that contain these protocols and delegates.

For example, if your module-Swift.h doesn't find "SlideNavigationControllerDelegate", you need to add in the Objective-C file (which use "module-Swift.h") the line:
#import <iOS_Slide_Menu/SlideNavigationController.h>