19

I just add facebookSDK.framework in ios project through this document :Getting Started with the Facebook SDK for iOS

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"

I was also add facebookSDK.framework in my Project's resource and try again but not solve it.

So, Please tell me how to do for run this project in other place.

ChandreshKanetiya
  • 2,414
  • 5
  • 27
  • 41
  • Check my answer in here: http://stackoverflow.com/questions/10925539/lexical-or-preprocessor-issue-file-not-found-occurs-while-archiving/32374354#32374354 also there are a lot of different answers inside. – OhadM Sep 03 '15 at 11:51

15 Answers15

32

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.

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.

This assumes that your framework is stored somewhere inside your project directory. If not, change the new search path as needed.

sffc
  • 6,186
  • 3
  • 44
  • 68
  • This answer worked for me, but should be regarded as a temporary solution, as I had this problem in Xcode 4 but not Xcode 6 so it seems that Apple fixed it (I didn't have Xcode 5 installed). Xcode has a lot of problems with caching, so usually it works best to 1) remove an offending item from the project 2) Clean 3) Organizer->Project->Delete Derived Data 4) Quit Xcode 5) Relaunch Xcode and re-add the item. – Zack Morris Dec 09 '14 at 00:13
  • This also seemed to help in Version 6.2 (6C121). – Gabe Rainbow Apr 23 '15 at 23:39
  • great.. helped me too – Syed Ali Salman May 06 '15 at 07:05
4

I had this problem and fixed it by doing this:

  1. Delete the FacebookSDK framework from your project.
  2. 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)
  3. Clean your project, save and quit.
  4. Relaunch your project.
  5. Re-add the Facebook SDK framework by dragging into your project.
  6. Compile. At this point, it was fixed for me.
Shaun Budhram
  • 3,690
  • 4
  • 30
  • 41
  • for me - I had included the sdk in a mercurial repository. It appears that following these steps above but also reverting to the Documents/Facebook SDK instead of my projects folder has fixed problem. – johndpope Sep 04 '14 at 07:38
  • I didn't have to do step 2 either. – Sam Critchley Jan 05 '15 at 21:24
3

In my case I did things similar to you (one thing is different), it worked for me. The steps are below:

  1. Go the FacebookSDK directory, select FacebookSDK.framework, right click and press get info then copy the file path.(something like : /Users/macbook/Documents/FacebookSDK)

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

  3. Be aware this setting exists both under 'Project' and 'Target', so paste it in both places.

  4. Clean project and build. This time it should work.

sth
  • 222,467
  • 53
  • 283
  • 367
Saleh Masum
  • 2,137
  • 1
  • 16
  • 16
  • Spent yesterday, whole day banging my head. Came this morning, found this, did exactly like this, solved. Thank you so much life saver. – Kiran Thapa Feb 26 '15 at 02:01
2

My solution to the Lexical or Preprocessor Issue - file not found error, was as follows:

Go to Xcode => Project Target => Build Settings => Search Paths

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"

1

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.

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"

This may not directly help with the OP's question, but may hopefully help others like me.

JoeBilly
  • 3,057
  • 29
  • 35
scudsucker
  • 11
  • 1
1

In my case the problem was with MillenialMedia SDK:

Lexical or Preprocessor Issue 'MillennialMedia/MMSDK.h' file not found

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.

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.

Removing frameworks Removing frameworks

Moving framevorks from inner folder to top-level Project folder (Same folder, where your .xcodeproj file is stored Moving framevorks from inner folder to top-level Project folder

Adding frameworks back to the project Adding frameworks back to the project

fir
  • 387
  • 1
  • 3
  • 19
0
  • Click on the blue icon from your files browser in xcode (the top one with your project name)
  • Click on targets, then build phases.
  • Expand compile sources.
  • Add your Facebook.m files there.

That should do it.

If not, just clean your project (command + shift + k), and then re-add the framework (Y).

If you have any more questions, just ask ;D

Albara
  • 1,306
  • 8
  • 14
0

I have same problem. Maybe you used tortoiseSVN (windows) to checkout source code.

This is my problem:

Mac => submit source => Window => checkout source => Copy source from window to Mac => compile => error.

Solution: using svn for Mac to checkout source.

FixBug
  • 355
  • 2
  • 17
0

In my case it was Xcode and its lovely feature of F***ing up stuff :)

Solution: Go to "Build Settings" in Xcode, and under "Search Paths" there is a "Framework Search Paths" item. Make sure you don't have slashes before the quotes, which are usually added when you add a framework via the "Add files to..." on Xcode. If you see slashes before the quote, remove them. example:

\"

Should be

"
IncrediApp
  • 10,303
  • 2
  • 33
  • 24
0

When I had this problem I found that the project came back clean but when I tried to run it I got the error. If I commented out the facebook.h files then it just switched to the next files in my prefix file and still created the error.

I was ready to start changing the build settings and search paths but decided to close all my Xcode projects and restart it first which worked for me.

Writing this it seems almost too obvious a thing to try but as soon as the error appeared I was onto stackoverflow and trying the answers suggested above. My situation might be rare and unique but definitely try restarting and closing everything first as it only takes 10 seconds and worked for me.

sam_smith
  • 6,023
  • 3
  • 43
  • 60
0

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

  1. Make sure that there is nothing in the library search path.
  2. Now click on the project (above target)->Build settings and repeat steps 7 and 8.
  3. 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.

geekay
  • 1,655
  • 22
  • 31
Abhishek Kumar
  • 324
  • 2
  • 8
0

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

You can check all "Framework Search Paths" in your project and make sure Xcode only can find one "facebookSDK.framework" in those paths.

0

The values in Framework Search Paths and Header Search Paths were 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.

The problem was with the folder name of downloaded SDK

I renamed it to FacebookSDK and got my app up and running

Supriya Kalghatgi
  • 1,155
  • 9
  • 10
0

If you are using this command line for the facebook plugin on IOS

 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.

rstephen
  • 19
  • 5
-1

vote539 is correct, but...

Blockquote Go to "Build Settings" in Xcode, and under "Search Paths" there is a "Framework Search Paths" item.

Then double-click the current paths for "Framework Search Paths".

A window will appear. For the item $(PROJECT_DIR)/yourAppName, change from recursive to recursive.

The cause of the issue is that you put your frameworks in a subdirectory, rather them being in the root directory.

Collin Thomas
  • 1,590
  • 1
  • 13
  • 12