Linking Objective-C Libraries to Swift Frameworks
Опубликовано вс, 10/06/2019 - 15:54 пользователем MaximToday I have faced issue to adding Objective-C Libraries to Swift Frameworks.
I found many tutorials but only one of them really helped me. I will provide link to original post below on the end of the current post.
- First we have to create modulemap.map file that lists all of the header files part of the library.
In my case I need to add Header of TryCatchHandler.h. So I created folder TryCatchHandler and put modulemap.map to it - We have two ways how to add headers to file
- Add all headers you need directly to this file as below:
module TryCatchHandler {
header "TryCatchHandler.h"
header "TryCatchHandler1.h"
header "TryCatchHandler2.h"
} - Create ambrella header file, you can name it like you want, for instance
TryCatchHandlerFramework.h
- Put down all headers you need to ambrella framework:
#import "MyHeader1.h"
#import "TryCatchHandler.h"
#import "TryCatchHandler1.h"
#import "TryCatchHandler2.h" - Add ambrella header to modulemap.map
module
TryCatchHandler{
umbrella header "TryCatchHandlerFramework.h"
export *
} -
The export * implies that all imported headers in the umbrella header to be part of the module.
- Put down all headers you need to ambrella framework:
-
Finally you need to place this newly created module map in the same directory as the header files
-
Once you have the module map in place, you need to update a few build settings
-
Link the library to the appropriate target (app or framework). Complete this by dragging the binary library file into Linked Frameworks and Libraries section under the general tab in build settings
-
With your target selected, under build settings, add the Library path to the following
-
Import Paths
-
Header Search Paths
-
Library Search Paths
-
-
-
In original port there is step to add the module map file location to Private Module Map File
BUT THIS STEP DOES NOT WORK FOR ME, if I complete this step I have error: Redefinition of module TryCatchHendler
I left Private Module Map File empty
- Add all headers you need directly to this file as below:
The original articl you can find here
Enjoy!