Curtis
Curtis

Reputation: 2535

How to make Xcode find file FacebookSDK.h?

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>
{
}

Upvotes: 47

Views: 58604

Answers (17)

Mohammed Raisuddin
Mohammed Raisuddin

Reputation: 992

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.

Upvotes: 0

Kimy BF
Kimy BF

Reputation: 1079

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.

Upvotes: 0

Tyrone
Tyrone

Reputation: 11

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"

Upvotes: 0

Mohit Tomar
Mohit Tomar

Reputation: 5201

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.

Upvotes: 0

Abhishek Kumar
Abhishek Kumar

Reputation: 324

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.

Upvotes: 5

Zhang
Zhang

Reputation: 11607

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.

Upvotes: 1

Chico
Chico

Reputation: 80

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

Upvotes: 0

Arjay Waran
Arjay Waran

Reputation: 433

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

Upvotes: 1

arttioz
arttioz

Reputation: 265

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.

Upvotes: 0

Hugo
Hugo

Reputation: 2129

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

Upvotes: 24

Anna Billstrom
Anna Billstrom

Reputation: 2492

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.

Upvotes: 0

Myrddin
Myrddin

Reputation: 81

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.

Upvotes: 0

neo
neo

Reputation: 1

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.

Upvotes: 0

poloDelaVega
poloDelaVega

Reputation: 1145

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

Upvotes: 0

Fede Cugliandolo
Fede Cugliandolo

Reputation: 1686

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.

Upvotes: 95

biloshkurskyi.ss
biloshkurskyi.ss

Reputation: 1436

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

Upvotes: 0

Maurizio
Maurizio

Reputation: 4169

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.

Upvotes: 9

Related Questions