微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在框架模块中引入非模块化头文件

如何解决在框架模块中引入非模块化头文件

我正在尝试使用 Flutter 在 iOS 上构建应用程序。该应用程序在 Android 上构建和运行良好,但该应用程序拒绝在 iOS 上构建。要构建应用程序,我使用命令 Flutter build ios

This is the error I receive when trying to build

Xcode's output:
↳
Command CompileSwift Failed with a nonzero exit code
Command CompileSwift Failed with a nonzero exit code
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/FBSDKLoginKit-framework-umbrella.h"
        ^
/Users/MyUsername/Dev/MyApp/ios/Pods/Target Support
Files/FBSDKLoginKit-framework/FBSDKLoginKit-framework-umbrella.h:13:9: note: in file included from
/Users/MyUsername/Dev/MyApp/ios/Pods/Target Support
Files/FBSDKLoginKit-framework/FBSDKLoginKit-framework-umbrella.h:13:
#import "FBSDKCoreKitImport.h"
        ^
/Users/MyUsername/Dev/MyApp/ios/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKCoreKitImport.h:29:1
0: error: include of non-modular header inside framework module 'FBSDKLoginKit.FBSDKCoreKitImport':
'/Users/MyUsername/Dev/MyApp/ios/Pods/Headers/Public/FBSDKCoreKit/FBSDKCoreKit.h'
 #import "FBSDKCoreKit/FBSDKCoreKit.h"
         ^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/FBSDKLoginKit-framework-umbrella.h"
        ^
/Users/MyUsername/Dev/MyApp/ios/Pods/Target Support
Files/FBSDKLoginKit-framework/FBSDKLoginKit-framework-umbrella.h:15:9: note: in file included from
/Users/MyUsername/Dev/MyApp/ios/Pods/Target Support
Files/FBSDKLoginKit-framework/FBSDKLoginKit-framework-umbrella.h:15:
#import "FBSDKDeviceLoginManager.h"
        ^
/Users/MyUsername/Dev/MyApp/ios/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginManager.h
:22:9: note: in file included from
/Users/MyUsername/Dev/MyApp/ios/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginManager.h
:22:
#import "FBSDKDeviceLoginManagerResult.h"
        ^
/Users/MyUsername/Dev/MyApp/ios/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginManagerRe
sult.h:22:9: error: include of non-modular header inside framework module
'FBSDKLoginKit.FBSDKDeviceLoginManagerResult':
'/Users/MyUsername/Dev/MyApp/ios/Pods/Headers/Public/FBSDKCoreKit/FBSDKAccesstoken.h'
#import <FBSDKCoreKit/FBSDKAccesstoken.h>
        ^
<unkNown>:0: error: Could not build Objective-C module 'FBSDKLoginKit'
Command CompileSwift Failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Analyzing workspace
note: Constructing build description
note: Build preparation complete

Encountered error while building for device.

据我所知,主要问题来自错误

include of non-modular header inside framework module

我尝试按照 this solution 中的建议将 Allow Non-Modular Includes In Framework Modules 变成 YES,但这并没有改变任何东西。 This thread 提供了一个解决方案,涉及到框架 -> 目标 -> 构建阶段 -> 标题。但是我的项目没有这样的位置。

我对使用 Xcode 和构建 iOS 应用程序非常陌生,因此我们将不胜感激。

编辑:经过更多研究,我看到通过在导入结束时将 替换为 "" 解决了一些类似的错误,这样导入看起来像这样:

#import "FBSDKCoreKit/FBSDKAccesstoken.h"

这并没有消除错误,但我想我应该把它包括在这里,以防有人推荐这个解决方案。

解决方法

你走在正确的轨道上。 “非模块化”标头基本上是一个私有标头。错误是抱怨这样的标头是由公共标头导入(可能是递归的),实质上是将私有标头设为公开。这通常是意外或软件设计不良的迹象,因此最近的 Xcode 版本已将其转化为错误。

由于您在 3rd 方库中收到此错误,您的选择是

  • 获取该库的更新版本以修复错误
  • 降级到不将其视为错误的旧版本 Xcode (Xcode 11.7)
  • 找到一种方法来禁用 Xcode 中的错误。如果您可以以某种方式访问​​ Facebook SDK 的构建设置,则需要在其中设置“允许非模块化包含在框架模块中”,而不是在您的应用设置中

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。