如何让 Xcode 找到文件 FacebookSDK.h?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12849209/
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
How to make Xcode find file FacebookSDK.h?
提问by Curtis
It says "FacebookSDK/FacebookSDK.h file not found"
它说“找不到 FacebookSDK/FacebookSDK.h 文件”
Yet I can jump-to-definition on the #import and it takes me to the file.
然而,我可以在#import 上跳转到定义,它会将我带到文件。
And once I added the #import it now knows what FBFriendPickerDelegate is and it now doesn't have an error on that line.
一旦我添加了 #import,它现在就知道 FBFriendPickerDelegate 是什么,并且现在该行没有错误。
I have the facebookSDK.framework in my project and in the right folder. It's SDK 3.1. I tried adding search paths to /FacebookSDK and /FacebookSDK.framework and /FacebookSDK/Versions/A/Headers etc. I also tried #import "FacebookSDK.framework/Versions/A/Headers/FacebookSDK.h" and it still says it can't find it. I also tried clean and restarting. I have the latest version of Xcode.
我的项目和正确的文件夹中有 facebookSDK.framework。它是 SDK 3.1。我尝试将搜索路径添加到 /FacebookSDK 和 /FacebookSDK.framework 和 /FacebookSDK/Versions/A/Headers 等。我也尝试过 #import "FacebookSDK.framework/Versions/A/Headers/FacebookSDK.h" 并且它仍然说它可以没找到。我也尝试清理并重新启动。我有最新版本的 Xcode。
//
// FacebookView.h
//
#import <UIKit/UIKit.h>
#import <FacebookSDK/FacebookSDK.h>
@interface FacebookView : UIViewController <FBFriendPickerDelegate>
{
}
回答by Fede Cugliandolo
First, you have to remove your FacebookSDK.framework from your Project. Then start over again with these 5 steps. DO NOT re-link the framework.
首先,您必须从项目中删除 FacebookSDK.framework。然后从这 5 个步骤重新开始。不要重新链接框架。
- Go to Build Phases in your Project Target.
- In Link Binary With Libraries, click the "+" button.
- Click on "Add Other..." button
- Browse your FacebookSDK folder. Generally in ~/Documents/FacebookSDK/
- Clik on (select) "facebookSDK.framework" and then OPEN.
- 转到项目目标中的构建阶段。
- 在 Link Binary With Libraries 中,单击“+”按钮。
- 单击“添加其他...”按钮
- 浏览您的 FacebookSDK 文件夹。一般在 ~/Documents/FacebookSDK/
- 点击(选择)“facebookSDK.framework”,然后打开。
That's it.
就是这样。
回答by Hugo
No need to remove anything.
无需删除任何东西。
In your project go to: "Build Settings”, then “Search Paths". Look for "Frameworks Search Paths". You probably have something fixed like this:
在您的项目中,转到:“ Build Settings”,然后“ Search Paths”。寻找“框架搜索路径”。你可能有这样的固定:
Frameworks Search Paths: /Users/john/Documents/exampleappxyz
框架搜索路径:/Users/john/Documents/exampleappxyz
Change it to:
将其更改为:
Frameworks search paths: $(PROJECT_DIR)
框架搜索路径:$(PROJECT_DIR)
Voila!.
瞧!。
回答by Maurizio
I tried this but it did not work for me. I had to go into the Build Settings for the project and manually fix the FacebookSDK Framework Search Paths
to find the FacebookSDK.
我试过这个,但它对我不起作用。我必须进入项目的构建设置并手动修复 FacebookSDKFramework Search Paths
才能找到 FacebookSDK。
回答by Abhishek Kumar
Ok guys, I think i got the answer. Follow the steps given below.
好吧,伙计们,我想我得到了答案。按照下面给出的步骤操作。
- Copy your framework into your project.
- Make sure it is under some directory. e.g.
$(PROJECT_DIR)/project_name/Resources/Frameworks
- Click on the target.
- Goto Build Phases→Link binary with Libraries
- Add the custom framework by clicking "Add Other"
- Verify in the project navigator that the framework exists only once.
Now goto Build Settings→Search Paths→Framework Search Path and make sure that it has the following two things.
(a)
$(inherited)
(b)$(PROJECT_DIR)/project_name/Resources/Frameworks.
Not to remind the framework exists inside the
Frameworks
folder- Make sure that there is nothing in the library search path.
- Now click on the project (above target)→Build settings and repeat steps 7 and 8.
- Now clean the project and build the project.
- 将您的框架复制到您的项目中。
- 确保它在某个目录下。例如
$(PROJECT_DIR)/project_name/Resources/Frameworks
- 单击目标。
- 转到构建阶段→将二进制文件与库链接
- 单击“添加其他”添加自定义框架
- 在项目导航器中验证该框架仅存在一次。
现在转到 Build Settings→Search Paths→Framework Search Path 并确保它具有以下两项内容。
(a)
$(inherited)
(b)$(PROJECT_DIR)/project_name/Resources/Frameworks.
不提醒框架存在于
Frameworks
文件夹内- 确保库搜索路径中没有任何内容。
- 现在单击项目(目标上方)→构建设置并重复步骤 7 和 8。
- 现在清理项目并构建项目。
Hope it works. Please remember not to keep any folder names with spaces. If you have kept them, make sure that you provide the correct escape characters.
希望它有效。请记住不要保留任何带有空格的文件夹名称。如果您保留了它们,请确保提供正确的转义字符。
回答by Zhang
I got this problem today.
我今天遇到了这个问题。
It turns out I need to have my Framework search path in all three places:
事实证明,我需要在所有三个地方都有我的框架搜索路径:
1) Project Build Settings
2) App Target Build Settings
3) UnitTests Target Build Settings
My search path is:
我的搜索路径是:
/Users/myusername/Documents/FacebookSDK
After ensure that, the error disappeared for me.
在确保之后,错误对我来说消失了。
回答by Arjay Waran
How to remove facebook sdk links:
如何删除 facebook sdk 链接:
For those who like myself improperly added the facebook sdk. to remove the facebook SDK from your project,
对于那些喜欢我的人不正确地添加了facebook sdk。从您的项目中删除 facebook SDK,
check the link inside your frameworks folder, delete any facebook sdk link in there
检查您的框架文件夹中的链接,删除其中的任何 facebook sdk 链接
go into Build Phases -> Link Binary With Libraries and delete any facebook sdk in there
进入 Build Phases -> Link Binary With Libraries 并删除其中的任何 facebook sdk
Right click on the frameworks folder and select "show in finder" and delete any facebook sdk in there
右键单击框架文件夹并选择“在查找器中显示”并删除其中的任何 facebook sdk
Now follow "Fede Cugliandolo"'s steps and re add the facebook sdk
现在按照“Fede Cugliandolo”的步骤重新添加facebook sdk
回答by Chico
I had the same issue when I updated XCode, but in my case I didn't want to make any manual changes to the project settings as I use CMake to create it. You can find the way I fixed it here: https://stackoverflow.com/a/25564152/525873
我在更新 XCode 时遇到了同样的问题,但在我的情况下,我不想对项目设置进行任何手动更改,因为我使用 CMake 创建它。你可以在这里找到我修复它的方法:https: //stackoverflow.com/a/25564152/525873
回答by arttioz
Follow the instruction At step 4 Configure your Xcode ProjectI think you missing something. Delete the Facebook.sdk in your project and try again.
按照说明 在第 4 步配置您的 Xcode 项目我认为您遗漏了一些东西。删除项目中的 Facebook.sdk 并重试。
回答by biloshkurskyi.ss
I use xcode 5 and when add sdk it not correct write self address in "project.pbxproj".
我使用 xcode 5,当添加 sdk 时,它不正确地在“project.pbxproj”中写入自我地址。
Instead local address for sdk it save global address.
相反,sdk 的本地地址保存了全局地址。
I open "project.pbxproj" and finde the places of it and leave address only for sdk in project.
我打开“project.pbxproj”并找到它的位置并在项目中只留下sdk的地址。
<project name>/src/external/facebook
<project name>/src/external/testflight
to edit the entry was as follows
编辑条目如下
/Users/<user Name>/myProjects/.../ios/<project name>/src/external/facebook
回答by poloDelaVega
You have to change the property "Framework search path" in your build settings, and specify where the file FacebookSDK.framework is located (you can then use the SRCROOT variable to point to the root of your project directory, and thus, avoid using absolute paths ;)) e.g. :
您必须在构建设置中更改属性“框架搜索路径”,并指定文件 FacebookSDK.framework 所在的位置(然后您可以使用 SRCROOT 变量指向项目目录的根目录,从而避免使用绝对路径 ;)) 例如:
$(SRCROOT)/SampleProject/src/Utils/Facebook/
$(SRCROOT)/SampleProject/src/Utils/Facebook/
this is normally done automatically by Xcode when you import a third part framework, but it messes sometimes, (eg: when your modify your project directory tree...)
当您导入第三方框架时,这通常由 Xcode 自动完成,但有时会混乱,(例如:当您修改项目目录树时...)
Hope that helps...
希望有帮助...