How to make Xcode find file FacebookSDK.h?

匿名 (未验证) 提交于 2019-12-03 02:21:02

问题:

It says "FacebookSDK/FacebookSDK.h file not found"

Yet I can jump-to-definition on the #import and it takes me to the file.

And once I added the #import it now knows what FBFriendPickerDelegate is and it now doesn't have an error on that line.

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.

// //  FacebookView.h //  #import  #import   @interface FacebookView : UIViewController  { }

回答1:

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.

  1. Go to Build Phases in your Project Target.
  2. In Link Binary With Libraries, click the "+" button.
  3. Click on "Add Other..." button
  4. Browse your FacebookSDK folder. Generally in ~/Documents/FacebookSDK/
  5. Clik on (select) "facebookSDK.framework" and then OPEN.

That's it.



回答2:

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:

Frameworks Search Paths: /Users/john/Documents/exampleappxyz

Change it to:

Frameworks search paths: $(PROJECT_DIR)

Voila!.



回答3:

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.



回答4:

Ok guys, I think i got the answer. Follow the steps given below.

  1. Copy your framework into your project.
  2. Make sure it is under some directory. e.g. $(PROJECT_DIR)/project_name/Resources/Frameworks
  3. Click on the target.
  4. Goto Build Phases→Link binary with Libraries
  5. Add the custom framework by clicking "Add Other"
  6. Verify in the project navigator that the framework exists only once.
  7. 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

  8. Make sure that there is nothing in the library search path.
  9. Now click on the project (above target)→Build settings and repeat steps 7 and 8.
  10. Now clean the project and build the project.

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.



回答5:

How to remove facebook sdk links:

For those who like myself improperly added the facebook sdk. to remove the facebook SDK from your project,

check the link inside your frameworks folder, delete any facebook sdk link in there

go into Build Phases -> Link Binary With Libraries and delete any facebook sdk in there

Right click on the frameworks folder and select "show in finder" and delete any facebook sdk in there

Now follow "Fede Cugliandolo"'s steps and re add the facebook sdk



回答6:

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.



回答7:

I use xcode 5 and when add sdk it not correct write self address in "project.pbxproj".

Instead local address for sdk it save global address.

I open "project.pbxproj" and finde the places of it and leave address only for sdk in project.

/src/external/facebook /src/external/testflight

to edit the entry was as follows

/Users//myProjects/.../ios//src/external/facebook


回答8:

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. :

$(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...)

Hope that helps...



回答9:

besides adding the search path I also had to set the paths to recursive and remove "*.framework" from the "Sub Directories to Exclude" option for this to work.



回答10:

This happens if you have imported the facebookSDK twice and after having deleting some files.

For example, I imported the facebookSDK in $project/framework but I deleted it for some reasons. Then I imported it via ~/Documents/FacebookSDK but Xcode kept the old folder and search in it by default.

I have to remove all references and files of the old import to resolve my issue.



回答11:

I ended up checking my project directory, remove any old references to the framework file. Then, remove it from Build Phases/Search paths. Also remove the linked Framework. Restart Xcode, and do the process over again: drag Framework to Frameworks, don't copy in. Check the Build Phases/Search paths. include "#import ". Finally worked. Whew.



回答12:

Follow the instruction At step 4 Configure your Xcode Project I think you missing something. Delete the Facebook.sdk in your project and try again.



回答13:

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



回答14:

it is simple, you have to remove your FacebookSDK.framework from your Project.

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 ~/mohit/Documents/FacebookSDK/ Clik on (select) "facebookSDK.framework" and then OPEN.

Now copy this Target settings > framework search path into Project setting > framework search path.



回答15:

None of all answers above worked for me.

What finally did the trick for me was to change the structure of the plugin folder:

  1. Create folder: com.phonegap.plugins.facebookconnect/FacebookSDK

  2. Copy all content from: com.phonegap.plugins.facebookconnect/FacebookSDK.framework/Headers to com.phonegap.plugins.facebookconnect/FacebookSDK

  3. Copy com.phonegap.plugins.facebookconnect/Facebook.framework to com.phonegap.plugins.facebookconnect/FacebookSDK

And finally, change

#import 

to

#import "FacebookSDK/FacebookSDK.h"


回答16:

The only solution I found was:

  1. Remove the phonegap plugin: ionic plugin rm phonegap-facebook-plugin

  2. Clone the next plugin git clone: https://github.com/jeduan/cordova-plugin-facebook4.git

  3. Add the plugin manually: cordova -d plugin add PATH/cordova-plugin-facebook4 --variable APP_ID="*****" --variable APP_NAME="*****"

Before this a tried to re add FacebookSDK.framework and installed the phonegap plugin facebook through a locally cloned, but the error continues.



回答17:

Just follow these steps:

  1. Open Xcode's Build Settings tab in your project.
  2. Add ~/Documents/FacebookSDK to the project's Framework Search Paths setting.


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!