facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 907 forks source link

Could not find or use auto-linked library '..." #755

Open haveamission opened 4 years ago

haveamission commented 4 years ago

🐛 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):

ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find or use auto-linked library 'swiftCompatibility50'
ld: warning: Could not find or use auto-linked library 'swiftObjectiveC'
ld: warning: Could not find or use auto-linked library 'swiftFoundation'
ld: warning: Could not find or use auto-linked library 'swiftsimd'
ld: warning: Could not find or use auto-linked library 'swiftDarwin'
ld: warning: Could not find or use auto-linked library 'swiftUIKit'
ld: warning: Could not find or use auto-linked library 'swiftCore'
ld: warning: Could not find or use auto-linked library 'swiftQuartzCore'
ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find or use auto-linked library 'swiftPhotos'
ld: warning: Could not find or use auto-linked library 'swiftSwiftOnoneSupport'
ld: warning: Could not find or use auto-linked library 'swiftCoreImage'
ld: warning: Could not find or use auto-linked library 'swiftCompatibilityDynamicReplacements'
ld: warning: Could not find or use auto-linked library 'swiftMetal'
ld: warning: Could not find or use auto-linked library 'swiftDispatch'
ld: warning: Could not find or use auto-linked library 'swiftAVFoundation'
ld: warning: Could not find or use auto-linked library 'swiftCoreMedia'
ld: warning: Could not find or use auto-linked library 'swiftCoreAudio'
ld: warning: Could not find or use auto-linked library 'swiftCoreMIDI'
ld: warning: Could not find or use auto-linked library 'swiftCoreLocation'
Undefined symbols for architecture x86_64:
  "protocol descriptor for Foundation.CustomNSError", referenced from:
      protocol conformance descriptor for __C_Synthesized.related decl 'e' for FBSDKLoginError : Foundation.CustomNSError in __C_Synthesized in libFBSDKLoginKit.a(LoginManager.o)
  "method descriptor for static Foundation.CustomNSError.errorDomain.getter : Swift.String", referenced from:
      protocol conformance descriptor for __C_Synthesized.related decl 'e' for FBSDKLoginError : Foundation.CustomNSError in __C_Synthesized in libFBSDKLoginKit.a(LoginManager.o)
  "method descriptor for Foundation.CustomNSError.errorUserInfo.getter : [Swift.String : Any]", referenced from:
      protocol conformance descriptor for __C_Synthesized.related decl 'e' for FBSDKLoginError : Foundation.CustomNSError in __C_Synthesized in libFBSDKLoginKit.a(LoginManager.o)
  "method descriptor for Foundation.CustomNSError.errorCode.getter : Swift.Int", referenced from:
      protocol conformance descriptor for __C_Synthesized.related decl 'e' for FBSDKLoginError : Foundation.CustomNSError in __C_Synthesized in libFBSDKLoginKit.a(LoginManager.o)
  "base conformance descriptor for Foundation.CustomNSError: Swift.Error", referenced from:
      protocol conformance descriptor for __C_Synthesized.related decl 'e' for FBSDKLoginError : Foundation.CustomNSError in __C_Synthesized in libFBSDKLoginKit.a(LoginManager.o)
  "protocol descriptor for Foundation._ErrorCodeProtocol", referenced from:

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

AndrewJack commented 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

a-metta commented 4 years ago

is it possible to add this to the documentation as a setup step? lost a whole day on this

tolik85 commented 4 years ago

How come such a show stopper requirement isn't in bold in the installation steps?

ParshantArora commented 4 years ago

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

patavee commented 4 years ago

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.

ramirobg94 commented 4 years ago

I added this PR to improve the readme, https://github.com/facebook/react-native-fbsdk/pull/767

cglacet commented 4 years ago

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

cglacet commented 4 years ago

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

  1. Dans Xcode, faites un clic droit sur le fichier Info.plist de votre projet et sélectionnez Open As -> Source Code.
  2. 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>
  1. 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.

LuisMendoza7 commented 4 years ago

I'm having the same issue and followed the same steps to build this.

but still i'm getting the same errors, do anyone have managed to successfully build it?

cglacet commented 4 years ago

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

stelselim commented 4 years ago

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.

oailloud commented 4 years ago

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!

jorgeants commented 4 years ago

Thanks @oailloud! It's work for me.

AndrewKeplinger commented 4 years ago

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.

waqaramjad commented 4 years ago

do we only have to create a .swift file and nothing written in it? what code I have to put in that file?

haveamission commented 4 years ago

@waqaramjad Empty Swift file seems to work just fine

joarwilk commented 4 years ago

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

AndrewKeplinger commented 4 years ago

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.

captaincole commented 4 years ago

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

raynox commented 4 years ago

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.

lkw1830 commented 4 years ago

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.

same issue here.

PolGuixe commented 4 years ago

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.

Same issue here...

asukhariev commented 4 years ago

Getting this error on 63.2. Anybody found how to debug and solve? thanks

2xSamurai commented 4 years ago

@oailloud Thank you.

for me this was enough.

  1. open XCode (workspace file)
  2. Right click project name and add a new swift file leave it as File.swift
  3. confirm "Create Bridging Header"
  4. clean and build

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!

vrazn commented 4 years ago

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.

ghost commented 4 years ago

My XCode doesn't ask for "Create Bridging Header" file. Anyone knows a solution?

ghost commented 4 years ago

@vrazn Have you any example of the content of the Bridging Header File?

bernica commented 4 years ago

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

bernica commented 4 years ago

The file is just an empty .h file.

tenondecrpc commented 4 years ago

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.

screen

jonathasgabriel commented 4 years ago

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

jeswcollins commented 4 years ago

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

ghost commented 4 years ago

I've created the file manually

Biplovkumar commented 4 years ago

@oailloud thanks. It helped.

d3f0lt-code commented 4 years ago

@emilioheinz when creating the file. Try to check in the targets the tests. Sample MyUpTests. check it.

christinasund commented 3 years ago

I tried all the solutions above and none worked. Then I tried:

  1. Open example.xcworkspace
  2. Clean (Command + Shift + K + Option)
  3. Delete derived data
  4. Run the project in Xcode (should succeed)

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!

TheFunktory commented 3 years ago

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

Screen Shot 2020-12-13 at 10 25 54 PM

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?

raboija commented 3 years ago

Same issue as @TheFunktory and @emilioheinz. Did you find a solution?

ghost commented 3 years ago

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.

@raboija That solved the issue for me

marcpope commented 3 years ago

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.

ghost commented 3 years ago

In some cases (idk why) the Bridging-Header file is not auto created, creating it manually solved it for me.

maluramichael commented 3 years ago

Adding a .swift file + generating the Bridging Headers fixt our problems. Thank you @AndrewJack

rosortoa commented 3 years ago

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

igristov commented 3 years ago

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.

kuznetsov-online commented 3 years ago

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
ngocdaothanh commented 3 years ago

In case you see the issue after updating React Native from 0.63.x to 0.64.x, try this solution:

iamvucms commented 3 years ago

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