How to make Xcode find file FacebookSDK.h?
Asked Answered
A

17

47

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 <UIKit/UIKit.h>
#import <FacebookSDK/FacebookSDK.h>

@interface FacebookView : UIViewController <FBFriendPickerDelegate>
{
}
Anatto answered 11/10, 2012 at 21:59 Comment(0)
I
95

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.

Ironsides answered 12/10, 2012 at 5:54 Comment(12)
I did that. The only way I got it work is by doing #import "FacebookSDK.framework/Versions/A/Headers/FacebookSDK.h"Anatto
First, you have to remove your FacebookSDK.framework from your Project. Then start over again with those 5 steps. DO NOT re-link the frameworkIronsides
i did this and getting this error ld: framework not found FacebookSDK clang: error: linker command failed with exit code 1 (use -v to see invocation)Iguana
@Iguana I got that error, and fixed it by restarting Xcode. This overall answer didn't work for me, though.Noyes
Did not work for me, and also added the framework into the project for an incorrect build target. The following then solved it: (1) In the project's file browser, locate the framework, and ensure its Target Membership is correct. (2) Per the answer below, go to Framework Search Paths and find the SDK in the list, but additionally set its option to 'Recursive'.Udo
Check my answer below. No need to remove the framework.Pamper
I tried this, it still doesn't work. and I also restart the xcode.Suckerfish
What do you mean "do not re-link the framework?" Isn't clicking the "+" button re-linking the framework?Adolfo
The current SDK only contains CoreKit, Login, ShareKit, Messenger, etc... I think there is an error on their compilation? since there is FacebookSDK.strings but FacebookSDK.framework is missing...Braca
@nferocious76 CoreKit, Login, ShareKit are in the new versions of the facebook SDK. I think you want an old version, eg 3.21.1 has it: developers.facebook.com/docs/ios/downloadsJellaba
Check your folder name. It's usually not just FacebookSDK. Mine was FacebookSDKs-iOS-xxxxxxxx with the x's being 8 digits. Check again for the correct name as this was the name that came when it was downloaded.Iinde
I was working with KIF and had an error with <KIF/KIF.h> not being found. I had to re-add KIF.framework to Link Binary With Libraries and it worked. Thanks!Perry
P
24

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

Pamper answered 17/3, 2014 at 2:53 Comment(3)
Your solution works as charm. And I believe this is the right answer.Pattern
I also think it's the right answer, but don't work for me; may still has others issue in my project. By the way, I copy the project from another machine.Suckerfish
@Suckerfish For this to work, your framework should be placed/copied in your project folder.Sufficient
M
9

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.

Medellin answered 27/2, 2013 at 16:0 Comment(4)
shareKit also error with this info :'FacebookSDK.h' file not foundCeramic
This helped! Projects where you work with other developers often missing $(SRCROOT) and has 'hard' paths to Libraries and Frameworks instead.Roydd
Perfect Boss... I set using (SRCROOT) in Framework Search Path it work in all system.Loverly
How do you accomplish that, specifically? Sorry, but in xcode one single wrong parameter ruins everything.Frit
C
5

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.

Coastwise answered 21/10, 2014 at 21:21 Comment(0)
P
1

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

Piranha answered 9/7, 2014 at 5:38 Comment(0)
C
1

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.

Compotation answered 29/10, 2014 at 7:4 Comment(0)
J
0

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.

<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
Jehad answered 9/10, 2013 at 11:41 Comment(0)
T
0

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

Throwback answered 9/12, 2013 at 16:59 Comment(0)
S
0

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.

Squander answered 1/2, 2014 at 2:0 Comment(0)
H
0

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.

Hendrick answered 13/2, 2014 at 9:23 Comment(0)
T
0

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.

Tephrite answered 6/3, 2014 at 5:19 Comment(0)
A
0

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.

Alvira answered 26/5, 2014 at 6:37 Comment(0)
A
0

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://mcmap.net/q/372144/-how-do-we-add-facebooksdk-into-a-xcode-project-using-cmake

Acton answered 20/10, 2014 at 9:37 Comment(0)
C
0

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.

Carroty answered 17/3, 2015 at 6:24 Comment(0)
R
0

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 <FacebookSDK/FacebookSDK.h>

to

#import "FacebookSDK/FacebookSDK.h"
Raina answered 9/5, 2015 at 13:52 Comment(0)
K
0

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.

Kasey answered 24/3, 2016 at 1:2 Comment(0)
S
0

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.
Stonecrop answered 18/10, 2016 at 12:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.