【问题标题】:error: using bridging headers with framework targets is unsupported错误:不支持将桥接头与框架目标一起使用
【发布时间】:2016-04-21 13:46:28
【问题描述】:

我有一个Objective C Cocoa Framework 我想在我的framework 中使用一个Swift 文件,但我添加了一个名称为<Project-name>-Swift.h 行的Bridging Header 文件。但是,当我运行它时,输出是:

:0: 错误:使用带有框架目标的桥接头是 不支持

【问题讨论】:

  • 设置桥接头路径
  • 我这样做了,但同样的错误再次发生
  • @ user3036749 - 可能是你删除了你的框架,但参考仍然可用。从你的项目中删除你的框架,然后再次添加框架,然后清理你的项目,然后构建你的项目。它会正常工作。快乐的编码。

标签: objective-c swift cocoa cocoa-touch


【解决方案1】:

伞形框架解决

  • 项目的桥接头

  • 框架的伞形文件


这是一个例子:

需要两个文件

fisherWebP-umbrella.h

&

fisherWebP.modulemap

放置它们的位置

在fisherWebP.modulemap中:

framework module Kingfisher{
  umbrella header "fisherWebP-umbrella.h"

  export *
  module * { export * }
}

在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

在 Xcode 中,

你需要fisherWebP-umbrella.h

不是fisherWebP.modulemap

然后设置fisherWebP-umbrella.h

settingsPackaging Options

PS:

您需要将 fisherWebP-umbrella.h 设置为公开

在 fisherWebP-umbrella.h 中导入的文件也应该设置为公开。

如:demux.h

递归地执行此操作。

PPS:

OTHER_SWIFT_FLAGS 设置为-Xcc -Wno-error=non-modular-include-in-framework-module 禁止快速导入错误。

( 在框架模块中包含非模块化头文件 )

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-12
    • 2023-03-29
    • 2020-06-23
    • 2023-01-10
    • 2016-05-02
    • 2014-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多