Open haveamission opened 4 years ago
facebook-ios-sdk v7 now requires that apps use the swift interfaces -https://github.com/facebook/facebook-ios-sdk/blob/master/CHANGELOG.md#700
Add a .swift
file to your project to embed the swift standard libs. See the repo's example app for reference - https://github.com/facebook/react-native-fbsdk/blob/master/example/ios/RNFBSDKExample/File.swift
is it possible to add this to the documentation as a setup step? lost a whole day on this
How come such a show stopper requirement isn't in bold in the installation steps?
PLease add this in the documentation Create a swift file in main project and add the following code to the same
File.swift // // File.swift // RNFBSDKExample // import Foundation
Just to note, you have to put File.swift
in the folder ios
and open Xcode then select the menu Product > Clean before I can successfully build it again.
I added this PR to improve the readme, https://github.com/facebook/react-native-fbsdk/pull/767
@AndrewJack, I'm not sure to get it, do we need to have only File.swift
or File.swift
together with AppDelegate.swift
, SceneDelegate.swift
as described in section 3 (I'll quote the section because I feel it states is quite unstable, for example the documentation talks about section 3 and 4 when it seems it wants to talk about 2 and 3, anyway)?
Step 3: Connect the App Delegate
Replace the code in
AppDelegate.swift
with the following code. This code initializes the SDK when your app launches, and allows the SDK handle results from the native Facebook app when you perform a Login or Share action:// AppDelegate.swift import UIKit import FBSDKCoreKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { ApplicationDelegate.shared.application( application, didFinishLaunchingWithOptions: launchOptions ) return true } func application( _ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:] ) -> Bool { ApplicationDelegate.shared.application( app, open: url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplication.OpenURLOptionsKey.annotation] ) } }
If you are using iOS 13 or above please add the following method to your
SceneDelegate
:// SceneDelegate.swift func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { guard let url = URLContexts.first?.url else { return } ApplicationDelegate.shared.application( UIApplication.shared, open: url, sourceApplication: nil, annotation: [UIApplication.OpenURLOptionsKey.annotation] ) }
I wonder why installing these dependencies is so hard and confusing.
I managed to make it work following another installation process: steps 3 and 4 here(only found this french but that should do):
Étape 3 : configurer info.plist
- Dans Xcode, faites un clic droit sur le fichier Info.plist de votre projet et sélectionnez Open As -> Source Code.
- Insérez l’extrait XML suivant dans le corps de votre fichier juste avant le dernier élément .
<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>fb{your-app-id}</string> </array> </dict> </array> <key>FacebookAppID</key> <string>{your-app-id}</string> <key>FacebookDisplayName</key> <string>{your-app-name}</string> <key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fb-messenger-share-api</string> <string>fbauth2</string> <string>fbshareextension</string> </array>
- Remplacez {your-app-id} et {your-app-name} par le nom et l’App ID de votre app indiqués dans l’Espace App Facebook.
Étape 4 : Connecter l’App Delegate
Pour post-traiter les résultats des actions nécessitant de passer à l’application native Facebook ou à Safari, telles que Facebook Login ou les boîtes de dialogue Facebook, vous devez connecter votre classe AppDelegate à l’objet FBSDKApplicationDelegate. Pour ce faire, ajoutez le code suivant à votre fichier AppDelegate.m.
// AppDelegate.m #import <FBSDKCoreKit/FBSDKCoreKit.h> - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // You can skip this line if you have the latest version of the SDK installed [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions]; // Add any custom logic here. return YES; } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey] ]; // Add any custom logic here. return handled; }
So there is no AppDelegate.swift
but instead you need to modify AppDelegate.m
. At least not for me. What a mess lol.
I'm having the same issue and followed the same steps to build this.
swift
file and put into ios folderbut still i'm getting the same errors, do anyone have managed to successfully build it?
@LuisMendoza7 Using the aforementioned build steps I managed to make it work. I only found this out of luck because I'm french (couldn't find these steps in the english version). There is a serious documentation problem for this install (links instead of a clear description).
I'm having the same issue and followed the same steps to build this.
- create a
swift
file and put into ios folder- clean build
but still i'm getting the same errors, do anyone have managed to successfully build it?
Did same but did not work using >0.60 version RN. is The problem about AppDelegate.m? I modified AppDelegate.m, did not work.
In my case, I had to create the swift file following this process: https://stackoverflow.com/a/56187043/1773450 (i.e. from XCode and creating the "Bridging Header").
So to sum it up, to update the lib I had to run
yarn ugrade --latest react-native-fbsdk
cd ios
pod update FBSDKLoginKit FBSDKShareKit FBSDKCoreKit
and then
I hope it helps... Good luck!
Thanks @oailloud! It's work for me.
I've done all of these steps and I'm still getting the original error from the bug report.
Compiling proper workspace, installed and updated cocoa pods, made the dummy swift file with the "Foundations" import in it, made other adjustments to xCode project generated by Unity.
I'm assuming that the messages "Could not find or use auto-linked library" directly leads to all of the undefined symbols.
I'm guessing that the libraries are being generated or exist somewhere and the app just isn't finding them. I'm going to try hunting them down now.
do we only have to create a .swift file and nothing written in it? what code I have to put in that file?
@waqaramjad Empty Swift file seems to work just fine
It's important that you create the file in XCode and not manually. It will generate a second file called <projectname>-Bridging-Header.h
. Seems like it's needed
I created the file using Xcode. I'm still not able to compile. I get about 100 errors after the warnings in this original bug report. Can't compile, not idea what to do next.
This solution helped me when I upgraded RN v0.62.2 but then I ran into a similar issue when I upgraded again to RN v0.63.2
Specifically, I'm only seeing 3 libraries from the fbsdk that are failing to be found
ld: warning: Could not find or use auto-linked library 'swiftWebKit'
ld: warning: Could not find or use auto-linked library 'swiftCoreMIDI'
ld: warning: Could not find or use auto-linked library 'swiftUniformTypeIdentifiers'
This is with react-native-fbsdk@2.0.0
I'm also struggling with that issue, first I had that issue when I was installing react-native-fbsdk
with react-native
: 62.2, I fixed that simply by adding a File.swift using Xcode. Then I tried to update react-native
to 63.2 and I ran into that issue again, but this time nothing helps.
I'm also struggling with that issue, first I had that issue when I was installing
react-native-fbsdk
withreact-native
: 62.2, I fixed that simply by adding a File.swift using Xcode. Then I tried to updatereact-native
to 63.2 and I ran into that issue again, but this time nothing helps.
same issue here.
I'm also struggling with that issue, first I had that issue when I was installing
react-native-fbsdk
withreact-native
: 62.2, I fixed that simply by adding a File.swift using Xcode. Then I tried to updatereact-native
to 63.2 and I ran into that issue again, but this time nothing helps.
Same issue here...
Getting this error on 63.2. Anybody found how to debug and solve? thanks
@oailloud Thank you.
for me this was enough.
In my case, I had to create the swift file following this process: https://stackoverflow.com/a/56187043/1773450 (i.e. from XCode and creating the "Bridging Header").
So to sum it up, to update the lib I had to run
yarn ugrade --latest react-native-fbsdk cd ios pod update FBSDKLoginKit FBSDKShareKit FBSDKCoreKit
and then
- open XCode
- create new file, select swift file
- confirm "Create Bridging Header"
- clean and build (I actually made my first build from XCode and then from react-native CLI)
I hope it helps... Good luck!
The problem re-appeared in our project with the new XCode version.
In our case the build was failing because of the YourProjectTests
target throwing the following three errors:
ld: warning: Could not find or use auto-linked library 'swiftWebKit'
ld: warning: Could not find or use auto-linked library 'swiftCoreMIDI'
ld: warning: Could not find or use auto-linked library 'swiftUniformTypeIdentifiers'
Deleting the .swift
file (if you already had it) and adding it back following the instructions above helped.
One thing to note is that you might need to specify the YourProjectTests
target when adding the file too, not just your main target.
My XCode doesn't ask for "Create Bridging Header" file. Anyone knows a solution?
@vrazn Have you any example of the content of the Bridging Header File?
@emilioheinz That's probably because you already created it once and deleted it. The file gets removed but the build settings configuration persists. Search your target's build settings for "Objective-C Bridging Header"
The file is just an empty .h file.
When creating the .swift file, another ProjectName-Bridging-Header.h file is also created, it is very important that when creating the file check in add to targets
option.
In my case, I had to create the swift file following this process: https://stackoverflow.com/a/56187043/1773450 (i.e. from XCode and creating the "Bridging Header").
So to sum it up, to update the lib I had to run
yarn ugrade --latest react-native-fbsdk cd ios pod update FBSDKLoginKit FBSDKShareKit FBSDKCoreKit
and then
- open XCode
- create new file, select swift file
- confirm "Create Bridging Header"
- clean and build (I actually made my first build from XCode and then from react-native CLI)
I hope it helps... Good luck!
Thank you @oailloud !!!
@emilioheinz If you already have a .swift file, try deleting it. Xcode didn't prompt me either I think because I had already tried making my own .swift file in a different folder. After I deleted it and made the file again in Xcode I was prompted for the header file.
I've created the file manually
@oailloud thanks. It helped.
@emilioheinz when creating the file. Try to check in the targets the tests. Sample MyUpTests. check it.
I tried all the solutions above and none worked. Then I tried:
I am now able to run successfully using yarn ios
Keep in mind I had already added the .swift file and bridging header.
Hope this helps someone else!
@bernica That's probably because you already created it once and deleted it. The file gets removed but the build settings configuration persists. Search your target's build settings for "Objective-C Bridging Header"
I'm in the same boat as @emilioheinz. I'm not prompted to do"Create Bridging Header". I searched for that build setting configuration and it is empty. Any advice from here?
Same issue as @TheFunktory and @emilioheinz. Did you find a solution?
The problem re-appeared in our project with the new XCode version. In our case the build was failing because of the
YourProjectTests
target throwing the following three errors:ld: warning: Could not find or use auto-linked library 'swiftWebKit' ld: warning: Could not find or use auto-linked library 'swiftCoreMIDI' ld: warning: Could not find or use auto-linked library 'swiftUniformTypeIdentifiers'
Deleting the
.swift
file (if you already had it) and adding it back following the instructions above helped. One thing to note is that you might need to specify theYourProjectTests
target when adding the file too, not just your main target.
@raboija That solved the issue for me
Creating File.swift in my main project folder fixed the issue for me... it auto created the (ProjectName)-Bridging-Header.h file, which appears to be empty.
In some cases (idk why) the Bridging-Header
file is not auto created, creating it manually solved it for me.
Adding a .swift file + generating the Bridging Headers fixt our problems. Thank you @AndrewJack
In my case, I had to create the swift file following this process: https://stackoverflow.com/a/56187043/1773450 (i.e. from XCode and creating the "Bridging Header").
So to sum it up, to update the lib I had to run
yarn ugrade --latest react-native-fbsdk cd ios pod update FBSDKLoginKit FBSDKShareKit FBSDKCoreKit
and then
- open XCode
- create new file, select swift file
- confirm "Create Bridging Header"
- clean and build (I actually made my first build from XCode and then from react-native CLI)
I hope it helps... Good luck!
Thanks @oailloud
When you create a new swift file in XCode via File/New menu make sure you select the checkbox corresponding your Target project. Otherwise you will not be prompted for Bridging Header creation and xxx-Bridging-Header.h file will not get created.
alternative 'file.swift' solution for Podfile
installer.aggregate_targets.first.user_project.native_targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(inherited)', '$(SDKROOT)/usr/lib/swift']
end
end
installer.aggregate_targets.first.user_project.save
In case you see the issue after updating React Native from 0.63.x to 0.64.x, try this solution:
Create a new 0.64.x project, for example:
npx react-native init MyApp --template react-native-template-typescript
Compare package.json
of the new project and of your old 0.63.x project, and modify the old one.
Do similarly with ios/Podfile
.
Run yarn install
or npm install
.
Run pod install
in ios
directory. Probably you need to remove the old Podfile.lock
file.
Now, when you rebuild your project, hopefully the issue will be fixed.
In my case, I had to create the swift file following this process: https://stackoverflow.com/a/56187043/1773450 (i.e. from XCode and creating the "Bridging Header").
So to sum it up, to update the lib I had to run
yarn ugrade --latest react-native-fbsdk cd ios pod update FBSDKLoginKit FBSDKShareKit FBSDKCoreKit
and then
- open XCode
- create new file, select swift file
- confirm "Create Bridging Header"
- clean and build (I actually made my first build from XCode and then from react-native CLI)
I hope it helps... Good luck!
Thanks a lot bro
🐛 Bug Report
Upon installing this library, and installing the pods, I try to run a build on the simulator. I get the following error (it was building properly before):
To Reproduce
Install library, install pods, try to build
Expected Behavior
Successful build
Environment
System: OS: macOS 10.15.1 CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz Memory: 200.69 MB / 16.00 GB Shell: 5.7.1 - /usr/local/bin/zsh Binaries: Node: 13.11.0 - /usr/local/bin/node Yarn: 1.17.3 - /usr/local/bin/yarn npm: 6.13.7 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 25, 27, 28 Build Tools: 25.0.2, 26.0.2, 28.0.3 IDEs: Android Studio: 3.4 AI-183.6156.11.34.5692245 Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild npmPackages: react: ^16.10.2 => 16.10.2 react-native: ^0.61.2 => 0.61.2 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1 react-native: 0.60.5