React-native-fbsdk: Could not find or use auto-linked library '..."

Created on 24 May 2020  路  43Comments  路  Source: facebook/react-native-fbsdk

馃悰 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

Most helpful comment

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!

All 43 comments

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

  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鈥檈xtrait 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鈥橝pp ID de votre app indiqu茅s dans l鈥橢space App Facebook.

脡tape 4 : Connecter l鈥橝pp Delegate

Pour post-traiter les r茅sultats des actions n茅cessitant de passer 脿 l鈥檃pplication native Facebook ou 脿 Safari, telles que Facebook Login ou les bo卯tes de dialogue Facebook, vous devez connecter votre classe AppDelegate 脿 l鈥檕bjet 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.

  • 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?

@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

  • 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! 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 [email protected]

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

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

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

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

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.

screen

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:

  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!

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

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 the YourProjectTests 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

Was this page helpful?
0 / 5 - 0 ratings