objective-c FBSDKCoreKit 的 Facebook iOS8 SDK 构建模块错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29435377/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 21:33:03  来源:igfitidea点击:

Facebook iOS8 SDK build module error for FBSDKCoreKit

objective-cios8facebook-ios-sdk

提问by star7anne

I am trying to add the Facebook SDK to my iOS 8 Objective-C app in Xcode. I did the install according to the FB-dev instructions. However, I get a "Could not build module 'FBSDKCoreKit'"error when I add the header to my AppDelegate.m file.

我正在尝试在 Xcode 中将 Facebook SDK 添加到我的 iOS 8 Objective-C 应用程序。我根据 FB-dev 说明进行了安装。但是,当我将标头添加到 AppDelegate.m 文件时,出现“无法构建模块 'FBSDKCoreKit'”错误。

#import "AppDelegate.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>

Based on what I read elsewhere

根据我在别处读到的

  1. I have already cleaned the build and re-installed Xcode.
  2. I also re-installed the Facebook SDK installer and tried to add it to a blank project (in case there was something corrupt with my app).
  3. I have double checked the plist and the framework files FB lists in the instructions, but nothing has seemed missing.
  1. 我已经清理了构建并重新安装了 Xcode。
  2. 我还重新安装了 Facebook SDK 安装程序并尝试将其添加到一个空白项目中(以防我的应用程序损坏)。
  3. 我已经仔细检查了说明中的 plist 和框架文件 FB 列表,但似乎没有遗漏任何东西。

I'm stumped.

我难住了。

回答by abjurato

FBSDKCoreKit can't be built because of "include of non-modular header inside framework module" error in FBSDKAppLinkResolver.h header file: in #import <Bolts/BFAppLinkResolving.h>line.

由于FBSDKAppLinkResolver.h 头文件中的“在框架模块中包含非模块化头文件”错误,无法构建 FBSDKCoreKit:内联 #import <Bolts/BFAppLinkResolving.h>

The solution from Swift compiler error: "non-modular header inside framework module"(switching CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES) did't help me.

来自Swift 编译器错误的解决方案:“框架模块内的非模块化头文件”(切换 CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES)对我没有帮助。

My solution:

我的解决方案:

  1. Create in Bolts.framework file module map: Modules/module.modulemap (like in FBSDKCoreKit.framework)
  2. Put such code inside

    framework module Bolts {
    umbrella header "Bolts.h"
    
    export *
    module * { export * }
    
    
    explicit module BFAppLinkResolver {
        header "BFAppLinkResolver.h"
        link "BFAppLinkResolver"
        export *
    }}
    
  1. 在 Bolts.framework 文件中创建模块映射:Modules/module.modulemap(如在 FBSDKCoreKit.framework 中)
  2. 把这样的代码放在里面

    framework module Bolts {
    umbrella header "Bolts.h"
    
    export *
    module * { export * }
    
    
    explicit module BFAppLinkResolver {
        header "BFAppLinkResolver.h"
        link "BFAppLinkResolver"
        export *
    }}
    

Interesting fact is that in FBSDKCoreKit such scheme is realized by Facebook, why didn't they apply it into Bolts...

有趣的是,在FBSDKCoreKit中这样的方案是由Facebook实现的,他们为什么不将其应用到Bolts中......

回答by vlad

Not sure if it has side effects but setting the "Allow Non-modular Includes in Framework modules" setting to YES in Build settings solved the problem for me. Hope it works for you too.

不确定它是否有副作用,但在构建设置中将“允许非模块化包含在框架模块中”设置为 YES 为我解决了这个问题。希望它也适用于你。

回答by Randika Vishman

Just doing the following let me to build the app successfully.

只需执行以下操作即可成功构建应用程序。

In Build settings Set "Allow Non-modular Includes in Framework modules"flag to YES

And I didn't want to Set "Enable Modules"(c and Objective-C) to NO

在构建设置中将“允许非模块化包含在框架模块中”标志设置为YES

我不想将“启用模块”(c 和 Objective-C)设置为NO

enter image description here

在此处输入图片说明

回答by Daniil Bystrov

For Objective-C I used Paul Lehn answer from: https://developers.facebook.com/bugs/362995353893156/

对于 Objective-C,我使用了 Paul Lehn 的回答:https: //developers.facebook.com/bugs/362995353893156/

  1. Add the -ObjC flag to your project's Other Linker Flags build setting. (if you don't want add to project configs, for initialise buttons classes)
  2. "Allow Non-modular Includes in Framework modules" setting to YES in Build settings
  3. Set "Enable Modules" (c and Objective-C) to No
  1. 将 -ObjC 标志添加到项目的其他链接器标志构建设置中。(如果您不想添加到项目配置,则用于初始化按钮类)
  2. 在构建设置中将“允许非模块化包含在框架模块中”设置为是
  3. 将“启用模块”(c 和 Objective-C)设置为否

(also don't forget add frameworks, for me it was: "AdressBook" "QuartzCore" "CoreLocation" "CoreGraphics" and if still not added, also "UIKit" "Foundation" "CoreData")

(也不要忘记添加框架,对我来说是:“AdressBook”“QuartzCore”“CoreLocation”“CoreGraphics”,如果仍未添加,还有“UIKit”“Foundation”“CoreData”)

and its finally worked for me

它终于对我有用了

all this used for linked FBSDK in custom folder in my project folder not from~/Documents/FacebookSDK

所有这些都用于我的项目文件夹中的自定义文件夹中的链接 FBSDK,而不是来自~/Documents/FacebookSDK

回答by Muhammad Noman

Remove ModuleDirectory From FacebookCoreKit.framwork.

从 FacebookCoreKit.framework 中删除模块目录。

enter image description here

在此处输入图片说明

回答by Thuyen Trinh

From Chris Pan (Facebook Team): https://developers.facebook.com/bugs/362995353893156/

来自 Chris Pan(Facebook 团队):https: //developers.facebook.com/bugs/362995353893156/

The 4.0.1 release added module maps (which should have obviated the need for bridging headers) but it looks like that may have caused some other compatibility issues. We're working on a proper fix but another workaround is to remove the module maps manually from each of the FBSDK*Kit.framework bundles; e.g., rm -r ~/Documents/FacebookSDK/FBSDKCoreKit.framework/Modules/(and repeat for FBSDKLoginKit and FBSDKShareKit)

4.0.1 版本添加了模块映射(这应该消除了对桥接头的需求),但看起来这可能导致了其他一些兼容性问题。我们正在努力进行适当的修复,但另一种解决方法是从每个 FBSDK*Kit.framework 包中手动删除模块映射;例如,rm -r ~/Documents/FacebookSDK/FBSDKCoreKit.framework/Modules/(对 FBSDKLoginKit 和 FBSDKShareKit 重复)

As far as I know, we have 2 options to deal with this problem:

据我所知,我们有两种选择来处理这个问题:

  1. Remove all module maps as Chris said.
  2. Add a temporary (unofficial) missing module map file in Bolts.framework folder (in FacebookSDK folder). You should check if this folder is missing or not.
  1. 正如克里斯所说,删除所有模块映射。
  2. 在 Bolts.framework 文件夹(在 FacebookSDK 文件夹中)中添加一个临时(非官方)丢失的模块映射文件。您应该检查此文件夹是否丢失。

回答by ABS

If you are having issue with 'FBSDKCoreKit'You can try below solutions:

如果您遇到“FBSDKCoreKit”问题,您可以尝试以下解决方案:

  1. Goto Build Setting and search for "allow non-modular"and Set

    "Allow Non-modular Includes in Framework modules" flag to YES

  1. 转到构建设置并搜索“允许非模块化”并设置

    “允许非模块化包含在框架模块中”标志为 YES

enter image description here

在此处输入图片说明

  1. Go to Document/FacebookSDK folder

    then goto FBSDKCoreKit.framework

    In this folder Remove Modules folder. Then add the FacebookSDK library in your project.

  2. Set the Framework search path to "~/Documents/FacebookSDK"

    Steps to find Framework search Path

    Goto build setting of the project and search for "framework search path".

    Then add "~/Documents/FacebookSDK"

  1. 转到文档/FacebookSDK 文件夹

    然后转到 FBSDKCoreKit.framework

    在此文件夹中删除模块文件夹。然后在您的项目中添加 FacebookSDK 库。

  2. 将框架搜索路径设置为“~/Documents/FacebookSDK”

    查找框架搜索路径的步骤

    转到项目的构建设置并搜索“框架搜索路径”。

    然后添加“~/Documents/FacebookSDK”

enter image description here

在此处输入图片说明

Edit:

编辑:

please open the Framework search path in Facebook app and copy paste all the paths mentioned over there in your application.Similar to the path i have attached in below screen shots

请在 Facebook 应用程序中打开框架搜索路径,然后复制粘贴在您的应用程序中提到的所有路径。类似于我在下面的屏幕截图中附加的路径

enter image description here

在此处输入图片说明

This will fix your problem

这将解决您的问题

回答by Dragos Panoiu

Got this issue too, you need to set

也有这个问题,需要设置

Enable Modules (C and Objective-C)

to NO.

NO

回答by Sukhpal Singh

I have faced the same problem. The issue was that my project directory contained space in the name "Application Demo". That's why whenever I dragg the Facebook frameworks then it added space in Framework Search Paths in settings. Remove this space resolved the issue.

我遇到了同样的问题。问题是我的项目目录在名称“Application Demo”中包含空格。这就是为什么每当我拖动 Facebook 框架时,它都会在设置中的框架搜索路径中添加空间。删除此空间解决了问题。

回答by Aggressor

TL;DRRemove your Bolts.framework reference in your project.

TL;DR删除项目中的 Bolts.framework 引用。

None of these or any of the other answers worked for me (in my case). For my project we were switching from an older Facebook sdk and we had a Bolts.framework.

这些或任何其他答案都不适合我(就我而言)。对于我的项目,我们从较旧的 Facebook sdk 切换过来,我们有一个 Bolts.framework。

Reading the documentation

阅读文档

The SDK automatically loads its framework and resource dependencies.

SDK 会自动加载其框架和资源依赖项。

As such I think there is a collision going on. There was the Bolts.framework I had from before and then the new one that came when I downloaded the new FacebookSDK bundle (4.7 in this case).

因此,我认为发生了冲突。有我之前的 Bolts.framework,然后是我下载新的 FacebookSDK 包(在这种情况下为 4.7)时出现的新框架。

Removing my Bolts.framework fixes the problem (be sure to clean before rebuilding).

删除我的 Bolts.framework 解决了这个问题(在重建之前一定要清理)。