Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

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

Open
haveamission opened this issue May 24, 2020 · 47 comments
Open

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

haveamission opened this issue May 24, 2020 · 47 comments

Comments

@haveamission
Copy link

🐛 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
Copy link
Contributor

AndrewJack commented May 26, 2020

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
Copy link

a-metta commented May 27, 2020

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

@tolik85
Copy link

tolik85 commented May 30, 2020

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

@ParshantArora
Copy link

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
Copy link

patavee commented Jun 16, 2020

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 added a commit to ramirobg94/react-native-fbsdk that referenced this issue Jun 20, 2020
@ramirobg94
Copy link
Contributor

I added this PR to improve the readme, #767

@cglacet
Copy link

cglacet commented Jun 23, 2020

@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
Copy link

cglacet commented Jun 24, 2020

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
Copy link

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?

@cglacet
Copy link

cglacet commented Jun 28, 2020

@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
Copy link

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
Copy link

oailloud commented Jul 2, 2020

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!

@jorgeants
Copy link

jorgeants commented Jul 15, 2020

Thanks @oailloud! It's work for me.

@AndrewKeplinger
Copy link

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
Copy link

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

@haveamission
Copy link
Author

@waqaramjad Empty Swift file seems to work just fine

@joarwilk
Copy link

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
Copy link

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
Copy link

captaincole commented Aug 2, 2020

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
Copy link

raynox commented Sep 9, 2020

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
Copy link

lkw1830 commented Sep 10, 2020

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
Copy link

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
Copy link

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

@2xSamurai
Copy link

@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
Copy link

vrazn commented Sep 22, 2020

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.

@jonathasgabriel
Copy link

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
Copy link

@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
Copy link

ghost commented Oct 2, 2020

I've created the file manually

@Biplovkumar
Copy link

@oailloud thanks. It helped.

@d3f0lt-code
Copy link

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

janicduplessis pushed a commit that referenced this issue Nov 4, 2020
@christinasund
Copy link

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
Copy link

TheFunktory commented Dec 14, 2020

@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
Copy link

raboija commented Dec 30, 2020

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

@ghost
Copy link

ghost commented Dec 30, 2020

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
Copy link

marcpope commented Jan 1, 2021

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
Copy link

ghost commented Jan 2, 2021

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

@maluramichael
Copy link

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

@rosortoa
Copy link

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
Copy link

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
Copy link

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
Copy link

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.

@iamvucms
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests