在框架模块内包含非模块化标头

问题描述 投票:0回答:2

我正在尝试使用 Flutter 在 iOS 上构建一个应用程序。该应用程序在 Android 上构建并运行良好,但该应用程序拒绝在 iOS 上构建。为了构建应用程序,我使用命令

flutter build ios

这是我在尝试构建时收到的错误

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

我尝试按照

此解决方案
中的建议将
Allow Non-Modular Includes In Framework Modules
转为YES,但这并没有改变任何内容。 这个线程提供了一个解决方案,涉及到框架 - >目标 - >构建阶段 - >标题。然而我的项目没有这样的位置。

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

编辑:经过更多研究,我看到了一些类似的错误,通过在导入末尾用“”替换<>来解决,这样导入看起来像这样:

#import "FBSDKCoreKit/FBSDKAccessToken.h"

这并没有消除错误,但我认为我应该将其包含在此处,以防有人推荐此解决方案。

objective-c xcode flutter fbsdk
2个回答
1
投票

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

由于您在第三方库中遇到此错误,您的选择是

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

0
投票

要解决“在框架模块‘firebase_crashlytics.Crashlytics_Platform’内包含非模块化标头”错误,请按照以下步骤操作:

打开 Xcode。 单击项目导航器中的 Runner。 转到构建设置选项卡。 在搜索栏中,输入 Apple Clang - 语言 - 模块。 寻找选项 允许非模块化包含在框架模块中

。 6. 将此选项设置为

enter image description here

.在此输入代码

这应该可以解决错误。

© www.soinside.com 2019 - 2024. All rights reserved.