Reputation: 95
I have a Objective C Cocoa Framework
I want to use a Swift
file in my framework
but I added a Bridging Header
file with name <Project-name>-Swift.h
line. But, when I run it, the output is:
:0: error: using bridging headers with framework targets is unsupported
Upvotes: 3
Views: 5580
Reputation: 2699
umbrella framwork solves
bridging headers for projects
umbrella file for frameworks
here is an example:
two files needed
fisherWebP-umbrella.h
&
fisherWebP.modulemap
where to place them
in fisherWebP.modulemap:
framework module Kingfisher{
umbrella header "fisherWebP-umbrella.h"
export *
module * { export * }
}
in fisherWebP-umbrella.h
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "demux.h"
#import "mux.h"
#import "decode.h"
// what you need
in Xcode,
you need fisherWebP-umbrella.h
not fisherWebP.modulemap
then set fisherWebP-umbrella.h
in settings
, Packaging Options
,
PS:
you need set fisherWebP-umbrella.h as public
files imported in fisherWebP-umbrella.h, should set as public too.
such as : demux.h
do this recursively.
PPS:
set OTHER_SWIFT_FLAGS
to -Xcc -Wno-error=non-modular-include-in-framework-module
inhibit swift import error.
( Include of non-modular header inside framework module )
Upvotes: 2