【问题标题】:error: using bridging headers with module interfaces is unsupported Command CompileSwiftSources failed with a nonzero exit code错误:不支持将桥接头与模块接口一起使用 Command CompileSwiftSources failed with a nonzero exit code
【发布时间】:2023-03-29 20:45:01
【问题描述】:

我的一个静态库应用程序已切换到Xcode12。我正在尝试制作 XCFramework 分发。运行构建命令后,

xcodebuild archive -scheme "MySDK" -sdk iphoneos  -archivePath “./archives/ios.xcarchive” -SKIP_INSTALL=NO

当我将Build Settings -> Build Libraries for Distribution 切换到YES 时,我遇到了错误,

<unknown>:0: error: using bridging headers with module interfaces is unsupported
Command CompileSwiftSources failed with a nonzero exit code

** ARCHIVE FAILED **


The following build commands failed:
    CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler
    CompileSwiftSources normal armv7s com.apple.xcode.tools.swift.compiler
    CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(3 failures)

This answer 有效,但不幸的是创建.xcframework 需要设置选项分布YES

如何解决这个问题?

【问题讨论】:

    标签: ios xcode xcodebuild xcode12 xcframework


    【解决方案1】:

    Apple 似乎正在弃用桥接头以支持模块,但 their documentation 关于如何 包含 C 标头的信息缺失。而是在更详细的clang docs 中找到该信息。

    尝试从项目设置中删除桥接头,然后创建一个module.modulemap 文件:

    module MySdk {
       header "MySdk-Bridging-Header.h"
       export *
    }
    

    这有一些注意事项,例如需要在您的 swift 代码中 import MySdk 并理解 C 函数将被公开,但这让我克服了困难。

    我通过反复试验发现的一个技巧是将此模块映射文件和 C 标头包含在框架的 Headers 文件夹中。这允许任何使用该框架的应用程序自动将MySdk 检测为模块。

    【讨论】:

      猜你喜欢
      • 2020-06-23
      • 2019-03-27
      • 2022-12-28
      • 1970-01-01
      • 2021-07-16
      • 1970-01-01
      • 1970-01-01
      • 2018-12-12
      • 2020-02-23
      相关资源
      最近更新 更多