ios 找不到词法或预处理器问题“FacebookSDK/FacebookSDK.h”文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20065666/
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
Lexical or Preprocessor Issue 'FacebookSDK/FacebookSDK.h' file not found
提问by ChandreshKanetiya
I just add facebookSDK.frameworkin ios project through this document :Getting Started with the Facebook SDK for iOS
我只是通过此文档在 ios 项目中添加facebookSDK.framework:iOS 版 Facebook SDK 入门
I have successfully build and run my Xcode project by following it. But when I copy my Source code and run it on another PC following error is coming "Lexical or Preprocessor Issue 'FacebookSDK/FacebookSDK.h' file not found"
我已经按照它成功构建并运行了我的 Xcode 项目。但是当我复制我的源代码并在另一台 PC 上运行它时出现以下错误“词法或预处理器问题‘FacebookSDK/FacebookSDK.h’文件未找到”
I was also add facebookSDK.frameworkin my Project's resource and try again but not solve it.
我还在我的项目资源中添加了facebookSDK.framework 并重试但没有解决它。
So, Please tell me how to do for run this project in other place.
所以,请告诉我如何在其他地方运行这个项目。
回答by sffc
I have a very similar issue, but in my case it is with the Amazon Web Services SDK instead of the Facebook SDK. For me the problem turned out to be related to my framework load path.
我有一个非常相似的问题,但就我而言,它与 Amazon Web Services SDK 而不是 Facebook SDK 有关。对我来说,问题原来与我的框架加载路径有关。
Solution:Go to "Build Settings" in Xcode, and under "Search Paths" there is a "Framework Search Paths" item. Double-click it and add a new search path: .
and make it recursive. Clean and build.
解决方案:进入Xcode中的“Build Settings”,在“Search Paths”下有一个“Framework Search Paths”项。双击它并添加一个新的搜索路径:.
并使其递归。清洁和建造。
This assumes that your framework is stored somewhere inside your project directory. If not, change the new search path as needed.
这假设您的框架存储在您的项目目录中的某处。如果没有,请根据需要更改新的搜索路径。
回答by Shaun Budhram
I had this problem and fixed it by doing this:
我遇到了这个问题并通过这样做来解决它:
- Delete the FacebookSDK framework from your project.
- Delete any references to the Facebook SDK from your "Framework Search Paths" and "Header Search Paths" in Build Settings (be aware this setting exists both under 'Project' and 'Target', so clear it from both places)
- Clean your project, save and quit.
- Relaunch your project.
- Re-add the Facebook SDK framework by dragging into your project.
- Compile. At this point, it was fixed for me.
- 从您的项目中删除 FacebookSDK 框架。
- 从“构建设置”中的“框架搜索路径”和“标题搜索路径”中删除对 Facebook SDK 的任何引用(请注意,此设置同时存在于“项目”和“目标”下,因此请从两个位置清除它)
- 清理您的项目,保存并退出。
- 重新启动您的项目。
- 通过拖入您的项目重新添加 Facebook SDK 框架。
- 编译。在这一点上,它对我来说是固定的。
回答by Saleh Masum
In my case I did things similar to you (one thing is different), it worked for me. The steps are below:
在我的情况下,我做了与你类似的事情(一件事是不同的),它对我有用。步骤如下:
Go the FacebookSDK directory, select FacebookSDK.framework, right click and press get info then copy the file path.(something like : /Users/macbook/Documents/FacebookSDK)
Go to "Build Settings" in Xcode, and under "Search Paths" there is a "Framework Search Paths" item. Double-click it and paste the file path that you just copied.
Be aware this setting exists both under 'Project' and 'Target', so paste it in both places.
Clean project and build. This time it should work.
转到 FacebookSDK 目录,选择 FacebookSDK.framework,右键单击并按获取信息然后复制文件路径。(类似于:/Users/macbook/Documents/FacebookSDK)
转到 Xcode 中的“Build Settings”,在“Search Paths”下有一个“Framework Search Paths”项。双击它并粘贴您刚刚复制的文件路径。
请注意,此设置同时存在于“项目”和“目标”下,因此请将其粘贴到两个位置。
清理项目并构建。这次应该可以了。
回答by Gavin Norman
My solution to the Lexical or Preprocessor Issue - file not found error, was as follows:
我对词法或预处理器问题的解决方案 - 找不到文件错误,如下所示:
Go to Xcode => Project Target => Build Settings => Search Paths
转到 Xcode => 项目目标 => 构建设置 => 搜索路径
Then insert the following path in both Framework Search Paths and Library Search paths, using your own project name in this path: "${SRCROOT}//project name/facebookSDK/framework"
然后在框架搜索路径和库搜索路径中插入以下路径,在此路径中使用您自己的项目名称:“${SRCROOT}//project name/facebookSDK/framework”
回答by scudsucker
I solved this error message by dragging the DeprecatedHeaders
folder from the Facebook SDK (it lives in FacebookSDK/Versions/Current
) into the Frameworks
folder, next to the FacebookSDK.framework
.
我通过将DeprecatedHeaders
Facebook SDK(它位于FacebookSDK/Versions/Current
)中的Frameworks
文件夹拖到FacebookSDK.framework
.
Adding all manner of search paths (including .
as suggested above) did not help, nor does the answer from Mr_bem help - the .m
file already existed in the "compile sources"
添加各种搜索路径(包括.
上面建议的)没有帮助,Mr_bem 的答案也没有帮助 - 该.m
文件已经存在于“编译源”中
This may not directly help with the OP's question, but may hopefully help others like me.
这可能不会直接帮助解决 OP 的问题,但可能会帮助像我这样的其他人。
回答by fir
In my case the problem was with MillenialMedia SDK:
就我而言,问题出在 MillenialMedia SDK 上:
Lexical or Preprocessor Issue 'MillennialMedia/MMSDK.h' file not found
找不到词法或预处理器问题“MillennialMedia/MMSDK.h”文件
It was solved by removing SDK frameworks from project, moving frameworks to Project's top-level folder (Where stored .xcodeproj File). And then adding Frameworks to Project in Build Phases.
它通过从项目中删除 SDK 框架,将框架移动到项目的顶级文件夹(存储 .xcodeproj 文件的位置)来解决。然后在构建阶段将框架添加到项目中。
Sometimes you need to re-download SDK archive form official website (if it was corrupted or something like that). In my case it was happened after pushing my project to remote repository from office computer and pulling it from home computer.
有时您需要从官方网站重新下载 SDK 存档(如果它已损坏或类似的东西)。在我的情况下,这是在将我的项目从办公室计算机推送到远程存储库并从家用计算机中提取之后发生的。
Removing frameworks
删除框架
Moving framevorks from inner folder to top-level Project folder (Same folder, where your .xcodeproj file is stored
将 framevorks 从内部文件夹移动到顶级项目文件夹(同一文件夹,您的 .xcodeproj 文件存储在其中
Adding frameworks back to the project
将框架添加回项目
回答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.
- 将您的框架复制到您的项目中。
- 确保它在某个目录下。例如$(PROJECT_DIR)/project_name/Resources/Frameworks
- 单击目标。
- 去
Build Phases->Link binary with Libraries
- 通过单击添加自定义框架
"Add Other"
- 在项目导航器中验证该框架仅存在一次。
- 现在转到
Build Settings->Search Paths->Framework Search Path
并确保它具有以下两件事。
(a) $(inherited)
(b) $(PROJECT_DIR)/project_name/Resources/Frameworks.
(a) $(继承)
(b) $(PROJECT_DIR)/project_name/Resources/Frameworks。
Not to remind the framework exists inside the "Frameworks" folder
不提醒框架存在于“Frameworks”文件夹中
- 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.
- 确保库搜索路径中没有任何内容。
- 现在单击项目(目标上方)-> 构建设置并重复步骤 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 Harpseal Tsai
I had same problem and find out the reason of this error in my case is because there are more then one "facebookSDK.framework"can be found in the "Framework Search Paths".
我遇到了同样的问题,在我的案例中找出这个错误的原因是因为在“框架搜索路径”中可以找到不止一个“facebookSDK.framework”。
You can check all "Framework Search Paths" in your project and make sure Xcode only can find one "facebookSDK.framework" in those paths.
您可以检查项目中的所有“框架搜索路径”,并确保 Xcode 只能在这些路径中找到一个“facebookSDK.framework”。
回答by Supriya Kalghatgi
The values in Framework Search Pathsand Header Search Pathswere initially the same that mentioned here by others.
中的数值框架搜索路径和头文件搜索路径最初是这里提到的其他人一样。
I checked to link the library manually by dragging it to the Xcode. FB SDK's library were already present as well.
我通过将它拖到 Xcode 来检查手动链接库。FB SDK 的库也已经存在。
The problem was with the folder name of downloaded SDK
问题在于下载的 SDK 的文件夹名称
I renamed it to FacebookSDKand got my app up and running
我将它重命名为FacebookSDK并启动并运行了我的应用程序
回答by rstephen
If you are using this command line for the facebook plugin on IOS
如果您将此命令行用于 IOS 上的 facebook 插件
cordova -d plugin add /path/to/cloned/phonegap-facebook-plugin --variable APP_ID="123456789" --variable APP_NAME="myApplication"
And you see the FacebookSDK.framework in your Frameworks but you are unable to expand it.
Go back and use cordova plugin remove phonegap-facebook-plugin
then
git clone https://github.com/Wizcorp/phonegap-facebook-plugin.git
and then re-add the facebook plugin.
您会在您的框架中看到 FacebookSDK.framework,但您无法扩展它。返回并使用cordova plugin remove phonegap-facebook-plugin
然后
git clone https://github.com/Wizcorp/phonegap-facebook-plugin.git
重新添加facebook插件。