在框架模块中包含非模块化标头
Posted
技术标签:
【中文标题】在框架模块中包含非模块化标头【英文标题】:Inlude of non-modular header inside framework Module 【发布时间】:2021-09-22 16:21:58 【问题描述】:我正在尝试使用 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"
这并没有消除错误,但我认为我应该将其包含在此处,以防有人推荐此解决方案。
【问题讨论】:
【参考方案1】:你在正确的轨道上。 “非模块化”标头基本上是私有标头。该错误抱怨公共标头正在(可能递归地)导入这样的标头,本质上使私有标头公开。这通常是意外或软件设计不佳的迹象,因此最近的 Xcode 版本已将其变为错误。
由于您在 3rd 方库中遇到此错误,您的选择是
获取修复错误的库的更新版本 降级到旧版本的 Xcode,不会将其视为错误 (Xcode 11.7) 找到一种方法来禁用 Xcode 中的错误。如果您可以通过某种方式访问 Facebook SDK 的构建设置,则需要在其中设置“允许框架模块中的非模块化包含”,而不是在您的应用设置中【讨论】:
感谢您的建议。我确保 FBSDK 是最新版本。此外,我尝试通过将“允许框架模块中的非模块化包含”设置为“是”来禁用该错误,但我收到了同样的错误。你还有什么其他的建议吗?以上是关于在框架模块中包含非模块化标头的主要内容,如果未能解决你的问题,请参考以下文章
具有依赖项的 CocoaPods 框架 - 在框架模块中包含非模块化标头