FBSDKCoreKit/FBSDKCoreKit.h 未发现错误

我正在实现 FB 登录,所以我从 https://developers.facebook.com/docs/ios下载 SDK。 然后我将 FBSDKCoreKitFBSDKLoginKitFBSDKShareKit框架拖到我的项目中。

当我运行项目时,它工作得很好。但当我关闭并重新打开它,然后 "FBSDKCoreKit/FBSDKCoreKit.h not found error"出现。然后再次我复制粘贴 FBSDKCoreKit框架到我的项目的库 然后错误就消失了,这个过程还在继续。以前有人遇到过这个问题吗?

我应该怎样解决这个错误?

105978 次浏览

Make sure to follow this step:

Deselect Copy items into destination group's folder. https://developers.facebook.com/docs/ios/getting-started/

Also, in your Build Settings, look at this field: "Framework Search Paths" You should have something like this:

/Users/[username]/Documents/FacebookSDK

or for a more general config

~/Documents/FacebookSDK

Also, look at Finder and make sure that the framework is actually there

I got to solve this by deleting the Framework and adding it again by right click on the project->Add files..., then choose the framework and SELECT the option to Copy files if needed. I know it's not what Facebook recommends, but I couldn't make it work doing that, but this way it worked! I'm using v4.6 of FBSDK and Xcode 7 beta 6. Hope it helps you and everyone else who's facing the same problem :)

Change the /Users/[username]/Documents/FacebookSDK/ directory to Documents/FacebookSDK like so:

xcode

I had a similar issue, and could not resolve the compiler error anyway.

I followed and performed the exact integration steps a few times, until I noticed that I have a copy of the FBSDKCoreKit.framework inside my project folder (happened probably by a mistake). In addition the Framework Search Paths already contains $(PROJECT_DIR) besides /Users/{username}/Documents/FacebookSDK.

So I've removed the copy of the FBSDKCoreKit.framework from the project's directory and now everything works fine.

I had the same problem. I fixed it by using quotes around my framework search path value i.e. "/Users/.....". Obviously, I have some spaces in my file paths.

Using CocoaPods, the only thing that worked for me was:

  1. Update Header Search Paths ( NOT Framework Search Paths ) under Build Settings in Xcode:

    - "\"${PODS_ROOT}/Headers/Public/Facebook-iOS-SDK\"",

    - "\"${PODS_ROOT}/Headers/Public/Facebook-iOS-SDK/FacebookSDK\"",

    + "\"${PODS_ROOT}/Headers/Public/FBSDKCoreKit\"",

    + "\"${PODS_ROOT}/Headers/Public/FBSDKCoreKit/FBSDKCoreKit\"",

  2. Add the missing header(s?):

    cd Pods/Headers/Public/FBSDKCoreKit/FBSDKCoreKit/ && ln -s ../../../../FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKCoreKit+Internal.h FBSDKCoreKit+Internal.h

Edit: point 2. needs apparently to be repeated after each following call to pod install.

FB developers say don't select copy files. Which creates problem. But I did opposite.

  1. I selected copy items if needed. It copied Frameworks in my project. Also automatically Search Path was added by xcode 7.2.

  2. Also double check if there is nothing in Framework Search Pathsunder Search Paths under Build Settings fields, then just add $(PROJECT_DIR) which is equal to /Users/user/Documents/....PROJECT..DIR...

Compiled in 2 projects successfully.

I have the same issue.I use Facebook SDK version 4.10.0.
I known my solution is not good but worked for me. I changed the Facebook source code. Changed the import file path from #import <FBSDKCoreKit/FBSDKCoreKit+Internal.h> to #import <FBSDKCoreKit/Internal/FBSDKCoreKit+Internal.h>

For Xcode 7.3, the below worked for me. Follow the steps mentioned on FB's guide and additionally do the below:

step 1. go to Document/FacebookSDK folder

step 2. Click FBSDKCoreKit.framework

step 3. In this folder Remove Modules folder and then drag and drop in your Xcode Project.

References : https://stackoverflow.com/a/29532202

Thanks

After updating Cocoapods 1.0.0, I deleted pod.lock and installed the current stable pod versions (4.7.0 to 4.11.0) of FBSDKCoreKit, FBSDKLoginKit, FBSDKShareKit

Then i encounter the same error. What i did was:

  1. Added Header Search Paths Build Settings in Xcode:

    "${PODS_ROOT}/Headers/Public/Facebook-iOS-SDK\"
    "${PODS_ROOT}/Headers/Public/Facebook-iOS-SDK/FacebookSDK\"
    "${PODS_ROOT}/Headers/Public/FBSDKCoreKit\"
    "${PODS_ROOT}/Headers/Public/FBSDKCoreKit/FBSDKCoreKit\"
    

Then i still had error for another file. Because XCode is using prebuild frameworks.

FBSDKCoreKit/FBSDKCopying.h not found

  1. Clean Build -> ⇧⌘K (Shift + Command + K) - to clean builded frameworks.
  2. Clean Build Folder -> ⌥⇧⌘K (Option+Shift+Command+K)
  3. Close Xcode // important! - Otherwise it recreate the DerivedData for the current open project automatically
  4. Run this command in terminal

    rm -rf ~/Library/Developer/Xcode/DerivedData
    
  5. Open XCode and build successfully

I ran into this issue last night, and wanted to post my solution just in case someone else has the same problem. My problem was my app was building and running fine in the sim and on my device, however the build would fail because of FBSDKCoreKit whenever I tried to run my unit tests. It took my about 30 minutes to find the problem, and I felt like a dummy when I did.

Make sure that the FBSDKCoreKit bundle is targeted for your tests as well, and not just your regular application build.

I had this problem when upgrading to Xcode 8 and was able to solve it by changing

#import <FBSDKCoreKit / FBSDKCoreKit.h>

to

#import <FBSDKCoreKit/FBSDKCoreKit.h>

This also took me hours of pain! Finally I found the root problem.

The Facebook SDK MUST be located at ~/Documents/FacebookSDK

This is because in the RCTFBSDK project this path is hardcoded. But you can add your custom location by adding it to the Framework Search Paths of the RCTFBSDK project (it will be shown in the error console)!

If any of the above answers didn't work, try this:

Open your ~/Documents/FacebookSDK folder. Check if there is this cloud icon right of the filenames:

screenshot.png

If so, macOS removed your files from your computer and uploaded them to iCloud! (thanks Apple)

You can:

  1. Click on all the cloud icons, it will download the files back
  2. Disable Storage Optimization on your mac to prevent it from happening again

When you add the directory to your Build Settings -> "Framework Search Paths", make sure you add it to both Debug AND Release.

Silly error but if you're new to iOS dev in xcode you could miss this.

For people moving from Carthage to Cocoapods make sure to remove the Carthage references of the FBSDKCoreKit from the Link Binary With Libraries under Build Phases option.

enter image description here

->Builds Configuration.

     -> Framework Search paths.

put the FacebookSDK directory in my case ~/Documents/FacebookSDK in :

Debugging,

Any architecture I Any Sdk,

Release.

especially this error because there no path in Any architecture I Any Sdk in my case

~ / Documents / FacebookSDK and it should be noted that the FacebookSDK folder must be in Domuments

Example

https://photos.app.goo.gl/5bD4d39a11AalYsx1

Personally I had trouble with spaces in various paths, including app name. Removing spaces (or adding "" everywhere to secure paths) solved the problem.

Solution to the problem if your FacebookSDK is different than

~/Documents/FacebookSDK

Because you don't want iCloud Drive to load up with FacebookSDK; you have to change the "Framework Search Paths" for the added

react-native-fbsdk

This is because in the RCTFBSDK.xcodeproj inside Libraires; path is hardcoded. But you can add your custom location by adding it to the Framework Search Paths of the RCTFBSDK project.

  1. Select the Project
  2. Libraries
  3. Select "RCTFBSDK.xcodeproj"
  4. Build Settings
  5. Add your custom path in "Framework Search Paths" eg: /Users/rajanmaharjan/FacebookSDK
  6. Clean Build -> ⇧⌘K (Shift + Command + K) - to clean build frameworks.
  7. Build the project; it should build successfully.

I had to move FacebookSDK path in Framework Search Paths above $(PROJECT_DIR)

$(SRCROOT)/../../../Documents/FacebookSDK
$(inherited)
$(PROJECT_DIR)

I had similar issue. Fix consisted for me in selecting: "COPY FILES IF NECESSARY" when manually adding the different frameworks into XCode framework.

I dragged the framework to the Framework folder inside xcode, chose to copy files if needed and all worked fine without any other configuration change.

For React Native devs:

Recommended steps to be done :

1.Make sure that the Facebook SDK frameworks are installed in ~/Documents/FacebookSDK.

2)Make sure that FBSDK[Core, Login, Share]Kit.framework show up in the Link Binary with Libraries section of your build target's Build Phases.

3)Make sure Framework Search Path of your build target's Build Settings is

$(HOME)/Documents/FacebookSDK

instead of

~/Documents/FacebookSDK

If it still doesn't work for you then:

1)sudo chmod -R 755 ~/Documents/FacebookSDK

2) set the path of framework search path of RCTFBSDK.xcodeproj to

  $(HOME)/Documents/FacebookSDK

(under libraries of your project folder ) set RCTFBSDK framework searchpath as here

clean your project (command+ shift + k ) and build.

I have installed react-native-fbsdk and link using react-native-link react-native-fbsdk.

Follow instruction of following link

https://developers.facebook.com/docs/react-native/configure-ios

This provide to link react-native library using ios_setup.js There are following step which i have followed.

  1. Setup on facebook developer account.

  2. Install the file ios_setup.js by executing the following command in a command prompt at your project's root folder.

curl -O https://raw.githubusercontent.com/facebook/react-native-fbsdk/master/bin/ios_setup.js

  1. Install the plist package, the xcode package, and the adm-zip package, by executing the following command. npm install plist xcode adm-zip
  2. Run the script ios_setup.js by executing the following command, and insert your app's App ID and App Name. If the name of your app is more than one word long, then enclose it between quotation marks.

node ios_setup.js [App ID] [App Name]

When run node ios_setup.js it wll automatically link all files in ios.

After troubleshooting using several answers here. This is what I did.

  1. I changed ~/Documents/FacebookSDK to "$(HOME)/Documents/FacebookSDK" note: I used quotes "
  2. I moved "$(HOME)/Documents/FacebookSDK" to the top of the list in header search paths.

Xcode 11 + CocoaPods solution

In root of your project, i.e. the same path where you have MyApp.xcworkspace open Terminal and init pod's pod init, then add the required FBSDK pods - your Podfile should look something like that:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!


# Pods for MyApp
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
end

Now in your Terminal pod install and open MyApp.xcworkspace (which is MyApp0 MyApp1). Go to MyApp -> Build Phases -> Link Binary with Libraries and you should see at the bottom of the list of frameworks Pods_MyApp.framework. If you'd click + below Pods_MyApp.framework you should in new window below Workspace a list of Pods where all related to FBSDK should be.

Note: Make sure you're installing FBSDK, not Facebook SDK, because the second one is outdated.

Had a same error in FBSDKLoginKit

If you use multiple pod projects

install! 'cocoapods',
:generate_multiple_pod_projects => true

Then you should force cocoapods to put all of FBSDK pods into a same project to make private headers visible

pod 'FBSDKCoreKit', '5.11.0', :project_name => 'FBSDK'
pod 'Bolts', '1.9.0', :project_name => 'FBSDK'
pod 'FBSDKShareKit', '5.11.0', :project_name => 'FBSDK'
pod 'FBSDKLoginKit', '5.11.0', :project_name => 'FBSDK'

Xcode with Facebook and iOS working - Step By Step

After much frustration I got my Iphone game building just fine. Following a combination of Ixgee's solution, and other solutions.

Fixes - FBSDKCoreKit.h not found and other related issues

  • I'm using Unity and Facebook SDK v11
  1. Unity -> ExternalDependencyManager -> IOS Resolver Settings - make it build to a Xcode project and make sure all the checkboxes are checked.

  2. MacOS -> move project to Mac. In Terminal in the project directory do the ‘sudo chmod +x process_symbols.sh’

2.5 Make sure you have cocoa pods installed. In Terminal type ‘sudo gem install cocoapods’

  1. MacOS->Podfile - the pod file in your project should look like this for Facebook SDK 11

    source 'https://cdn.cocoapods.org/'
platform :ios, '11.0'
    

target 'UnityFramework' do
pod 'FBSDKCoreKit', '~> 11.1.0', :modular_headers => true
pod 'FBSDKCoreKit_Basics', '~> 11.1.0'
pod 'FBSDKGamingServicesKit', '~> 11.1.0'
pod 'FBSDKLoginKit', '~> 11.1.0'
pod 'FBSDKShareKit', '~> 11.1.0'
end
target 'Unity-iPhone' do
end
use_frameworks! :linkage => :static
use_frameworks!

  1. [Only needs to be done once. If your Mac processor uses an ARM processor (like the M1)]] Terminal -> Type ‘sudo arch -x86_64 gem install ffi’

Solution from - https://github.com/CocoaPods/CocoaPods/issues/10723 [super helpful!]

  1. [If your Mac processor uses an ARM processor (like the M1)] Terminal -> ‘arch -x86_64 pod install’

Or

[If your Mac processor uses an x86 processor (like an Intel)] Terminal -> ‘pod install’

  1. Once the Pod Install is successful, double click the newly created ‘Unity-iPhone.xcworkspace’ in your project directory to open the workspace in Xcode.

  2. Xcode->The folder option -> Unity-IPhone-> under Projects select ‘UnityFramework’-> select ‘Build Phases’ then drag the ‘> Headers’ above the ‘> Compile Sources’ -Full details here (https://forum.unity.com/threads/xcode-version-13-3-13e113-error-cycle-in-dependencies.1268720/)

  3. Xcode -> In the Unity-phone - Build Settings -> Set - ALWAYS EMBED SWIFT STANDARD LIBRARIES: YES In the UnityFramework - Build Settings -> Set - ALWAYS EMBED SWIFT STANDARD LIBRARIES: NO Source - Validation Error: Invalid Bundle. The bundle at ... contains disallowed file 'Frameworks'

  4. VOILA! It builds to your iPhone with Facebook SDK Dependencies good to go on iOS!!!