简体   繁体   English

带有Cocoapods的Swift中的Facebook iOS SDK v 4.1.0:无法导入模块

[英]Facebook iOS SDK v 4.1.0 in Swift with Cocoapods: cannot import modules

I tried to update my Swift project to Facebook SDK v 4.1.0 today (FBSDKCoreKit and FBSDKLoginKit), but it doesn't seem to be working. 我今天尝试将我的Swift项目更新为Facebook SDK v 4.1.0(FBSDKCoreKit和FBSDKLoginKit),但似乎无法正常工作。 I cannot import the modules as they are not found. 我无法导入模块,因为找不到它们。

I basically removed the line 我基本上删除了线

pod 'Facebook-iOS-SDK' pod'Facebook-iOS-SDK'

and added the lines 并添加行

pod 'FBSDKCoreKit' 吊舱'FBSDKCoreKit'

pod 'FBSDKLoginKit' pod'FBSDKLoginKit'

and then did a pod install. 然后安装了pod。 The Facebook doc says the new SDK supports direct imports, so I tried Facebook的文档说新的SDK支持直接导入,所以我尝试了

import FBSDKCoreKit 导入FBSDKCoreKit

in one of my project files, but it says No such module 'FBSDKCoreKit' 在我的一个项目文件中,但是它说没有这样的模块“ FBSDKCoreKit”

I looked around and found the following links which talk about bug with building module, and the Facebook bug report and changelog: 我环顾四周,发现以下链接讨论了构建模块的错误以及Facebook错误报告和changelog:

issue using FBSDK in swift iOS application 快速的iOS应用程序中使用FBSDK的问题

https://developers.facebook.com/bugs/362995353893156/ https://developers.facebook.com/bugs/362995353893156/

https://developers.facebook.com/docs/ios/change-log-4.x https://developers.facebook.com/docs/ios/change-log-4.x

However, it seems to claim that the issue has been fixed in v 4.1.0 (seems to be the main reason for the update), so this isn't the problem in my case? 但是,似乎声称该问题已在4.1.0版中得到解决(似乎是更新的主要原因),所以这不是我的问题吗? Anyone have any information about this / have a solution? 有人对此有任何信息/有解决方案吗?

Try adding use_frameworks! 尝试添加use_frameworks! to the top of your podfile, as suggested by this answer . 根据此答案的建议,将其移到podfile的顶部。 Here's a blogpost that explains the issue. 这是一个解释问题的博客文章

I just ran into this problem of not being able to import the FBSDK directly into my files after I installed the sdk using cocoapods.. 使用cocoapods安装sdk后,我刚遇到无法将FBSDK直接导入文件的问题。

But after performing a build, the import statements worked fine! 但是在执行构建后,导入语句可以正常工作!

For some people experiencing this problem it might be as simple as that. 对于某些遇到此问题的人来说,就这么简单。

I know its an old post but thought to update the podfile for someone who would face the same issue i was facing. 我知道它的帖子很旧,但是想为可能遇到与我同样的问题的人更新podfile。

You can use this with iOS 9 and swift,once you run pod install you are good to go for 您可以在iOS 9和Swift上使用它,一旦运行pod install就可以了

import FBSDKLoginKit
import FBSDKShareKit
import FBSDKCoreKit

in swift files

-----Podfile------ ----- Podfile ------

# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
# Uncomment this line if you're using Swift
use_frameworks!


target 'FBIntegration' do

pod 'Bolts'
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'

end

If you have already added a bridging_header file you also can just add 如果您已经添加了bridging_header文件,也可以添加

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>

into it. 进去。 Then import directly 然后直接导入

import FBSDKLoginKit

Check here . 在这里检查。 Try with this in podfile: 在podfile中尝试一下:

pod 'FBSDKCoreKit', :git => 'https://github.com/facebook/facebook-ios-sdk.git', :branch => 'dev'
pod 'FBSDKLoginKit', :git => 'https://github.com/facebook/facebook-ios-sdk.git', :branch => 'dev'

You should use 你应该用

PROJECT.xcworkspace

file after editing Podfile and executing 编辑Podfile并执行后的文件

pod install

command, 命令,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM