可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am implementing FB Login so i Downloaded the SDK from https://developers.facebook.com/docs/ios.
then i drag n down FBSDKCoreKit
, FBSDKLoginKit
and FBSDKShareKit
frameworks into my project.
when i ran project it works fine. but when i closed and reopen it, then "FBSDKCoreKit/FBSDKCoreKit.h not found error"
appears. then again i copy paste FBSDKCoreKit
framework into my project's library
and error disappear and this process continues. anyone faced this problem before?
what should i do to solve this error?
回答1:
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
回答2:
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:
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
- Clean Build -> ⇧⌘K (Shift + Command + K) - to clean builded frameworks.
- Clean Build Folder -> ⌥⇧⌘K (Option+Shift+Command+K)
- Close Xcode // important! - Otherwise it recreate the DerivedData for the current open project automatically
Run this command in terminal
rm -rf ~/Library/Developer/Xcode/DerivedData
Open XCode and build successfully
回答3:
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 :)
回答4:
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)!
回答5:
FB developers say don't select copy files. Which creates problem. But I did opposite.
I selected copy items if needed. It copied Frameworks in my project. Also automatically Search Path
was added by xcode 7.2
.
Also double check if there is nothing in Framework Search Paths
under 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.
回答6:
I had to move FacebookSDK path in Framework Search Paths above $(PROJECT_DIR)
$(SRCROOT)/../../../Documents/FacebookSDK
$(inherited)
$(PROJECT_DIR)
回答7:
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:
If so, macOS removed your files from your computer and uploaded them to iCloud! (thanks Apple)
You can:
- Click on all the cloud icons, it will download the files back
- Disable Storage Optimization on your mac to prevent it from happening again
回答8:
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.
回答9:
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.
- Select the Project
- Libraries
- Select "RCTFBSDK.xcodeproj"
- Build Settings
- Add your custom path in "Framework Search Paths"
eg: /Users/rajanmaharjan/FacebookSDK
- Clean Build -> ⇧⌘K (Shift + Command + K) - to clean build frameworks.
- Build the project; it should build successfully.
回答10:
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.
回答11:
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>
回答12:
Using CocoaPods, the only thing that worked for me was:
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\"",
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
.
回答13:
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
回答14:
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.
回答15:
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 not MyApp.xcodeproj). 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.
回答16:
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.
回答17:
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.
回答18:
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>
回答19:
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.
回答20:
Personally I had trouble with spaces in various paths, including app name. Removing spaces (or adding "" everywhere to secure paths) solved the problem.
回答21:
I had similar issue. Fix consisted for me in selecting: "COPY FILES IF NECESSARY" when manually adding the different frameworks into XCode framework.
回答22:
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.
回答23:
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.
Setup on facebook developer account.
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
- Install the plist package, the xcode package, and the adm-zip package, by executing the following command.
npm install plist xcode adm-zip
- 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.
回答24:
After troubleshooting using several answers here. This is what I did.
- I changed
~/Documents/FacebookSDK
to "$(HOME)/Documents/FacebookSDK"
note: I used quotes "
- I moved
"$(HOME)/Documents/FacebookSDK"
to the top of the list in header search paths.
回答25:
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'
回答26:
->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
回答27:
Change the /Users/[username]/Documents/FacebookSDK/
directory to Documents/FacebookSDK
like so: