facebook / facebook-ios-sdk

Used to integrate the Facebook Platform with your iOS & tvOS apps.
https://developers.facebook.com/docs/ios
Other
7.78k stars 3.54k forks source link

dyld[38703]: Library not loaded: @rpath/FBSDKCoreKit.framework/FBSDKCoreKit #2121

Open salahelsayed99 opened 1 year ago

salahelsayed99 commented 1 year ago

Checklist before submitting a bug report

Xcode version

Version 13.1

Facebook iOS SDK version

15.0.0

Dependency Manager

CocoaPods

SDK Framework

Core

Goals

Avoid crash the app when i use the "15.0.0" version of sdk, if i used an oldest version everything is fine.

Expected results

Avoid crash

Actual results

App crashes in the beginning when i used "15.0.0" version of sdk, if i used an oldest version everything is fine.

I tried to use "use_modular_headers!". I tried to delete derived data.

Steps to reproduce

No response

Code samples & details

No response

liushengxu commented 1 year ago

is anyone working on a fix for this? This happens on Intel mac and this is pretty huge problem with current SDK version.

felipe-xavier commented 1 year ago

is anyone working on a fix for this SDK? This happens on Intel mac and this is pretty huge problem with current SDK version.

jamesho86 commented 1 year ago

blocked by this issue for a while and still waiting for a proper fix

Alex-sainyuk commented 1 year ago

xcode 14.2, project compiled from unity, same issue, manual adding works, but not good solution

mansilaad commented 1 year ago

+1 Same issue

katomizuki commented 1 year ago

+1 Same Issue

Frezyx commented 1 year ago

+1 Same Issue

jml0123 commented 1 year ago

WhatsApp Image 2022-11-11 at 13 33 19

I just add FBSDKCoreKit and FBSDKCoreKit_Basics and it works 🙌🏼

I tried this and get an error below:

Multiple commands produce '/Users/jsmglorenzo/Library/Developer/Xcode/DerivedData/Runner-feevmrclfhykhyhhhrdtlavvyvge/Build/Products/Debug-development-iphoneos/Runner.app/Frameworks/FBSDKCoreKit_Basics.framework'

Anyone else face this?

Edit: After downgrading to 14.1.0 like someone mentioned above, I am also getting an issue with not found symbols:

dyld[52084]: Symbol not found: (_$s8FBAEMKit11AEMReporterCN)
  Referenced from: '/private/var/containers/Bundle/Application/BBFBF781-7C77-43D5-BC32-3C0CB37D6FF1/Runner.app/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit'
  Expected in: '/private/var/containers/Bundle/Application/BBFBF781-7C77-43D5-BC32-3C0CB37D6FF1/Runner.app/Frameworks/FBAEMKit.framework/FBAEMKit'

Using: MacOs Monterey 12.3.1 Flutter 3.3.10 • channel stable Dart 2.18.6 • DevTools 2.15.0 Xcode 13.4.1

Definitely-Not-Vlad commented 1 year ago

@jml0123 After adding these to Frameworks, Libraries, and Embedded Content, you may have to remove them from Build Phases -> Link Binary With Libraries, so it's only in the Embed Frameworks build phase.

Note that you may also have to add FBSDKGamingServicesKit as well, at least I had to. Try without it first.

This worked for some, but not all of my projects.

I would really love for this to be resolved ASAP because it's blocking a ridiculous number of people. I'm not sure how I can help, but if anyone points me in the right direction I'm more than happy to give it a go.

jml0123 commented 1 year ago

@Definitely-Not-Vlad thanks for the tip! Unfortunately this alone didn't work for me. What finally worked using the 15.1.0 version was also to remove FBSDKCoreKit.framework from the [CP] Embed Pods Frameworks -> Output Files under Build Phases

Screen Shot 2022-12-22 at 11 21 32 AM Screen Shot 2022-12-22 at 11 23 38 AM

To recap in case someone is facing the same issue:

  1. I added FBSDKCoreKit_Basics and FBSDKCoreKit to Frameworks, Libraries and Embedded Content in General
  2. Removed FBSDKCoreKit_Basics and FBSDKCoreKit from Build Phases -> Link Binary With Libraries
  3. Removed reference to FBSDKCoreKit.framework from Build Phases -> [CP] Embed Pods Frameworks -> Output Files
ehdgns3136 commented 1 year ago

To recap in case someone is facing the same issue:

  1. I added FBSDKCoreKit_Basics and FBSDKCoreKit to Frameworks, Libraries and Embedded Content in General
  2. Removed FBSDKCoreKit_Basics and FBSDKCoreKit from Build Phases -> Link Binary With Libraries
  3. Removed reference to FBSDKCoreKit.framework from Build Phases -> [CP] Embed Pods Frameworks -> Output Files

@jml0123 Thanks! This is working for me. I'll write down what i did to make it work. I'm building iOS from Unity.

My environment:

Process:

  1. Version Up XCode 13.3 -> 14.1
  2. Open .xcworkspaces file, not .xcodeproj file Or it could generate module 'FBSDKCoreKit' not found error (This may only apply to Unity users)
  3. Add from General -> Frameworks, Libraries, and Embedded Content
    • FBSDKCoreKit_Basics.xcframework
    • FBSDKCoreKit.xcframework
    • FBSDKGamingServicesKit.xcframework Screen Shot 2022-12-23 at 6 07 22 PM
  4. Remove from Build Phases -> Link Binary With Libraries
    • FBSDKCoreKit_Basics.xcframework
    • FBSDKCoreKit.xcframework
    • FBSDKGamingServicesKit.xcframework
  5. Remove from Build Phases -> [CP] Embed Pods Frameworks
    • ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKCoreKit_Basics.framework
devibrahimkarahan commented 1 year ago

WhatsApp Image 2022-11-11 at 13 33 19 I just add FBSDKCoreKit and FBSDKCoreKit_Basics and it works 🙌🏼

I tried this and get an error below:

Multiple commands produce '/Users/jsmglorenzo/Library/Developer/Xcode/DerivedData/Runner-feevmrclfhykhyhhhrdtlavvyvge/Build/Products/Debug-development-iphoneos/Runner.app/Frameworks/FBSDKCoreKit_Basics.framework'

Anyone else face this?

Edit: After downgrading to 14.1.0 like someone mentioned above, I am also getting an issue with not found symbols:

dyld[52084]: Symbol not found: (_$s8FBAEMKit11AEMReporterCN)
  Referenced from: '/private/var/containers/Bundle/Application/BBFBF781-7C77-43D5-BC32-3C0CB37D6FF1/Runner.app/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit'
  Expected in: '/private/var/containers/Bundle/Application/BBFBF781-7C77-43D5-BC32-3C0CB37D6FF1/Runner.app/Frameworks/FBAEMKit.framework/FBAEMKit'

Using: MacOs Monterey 12.3.1 Flutter 3.3.10 • channel stable Dart 2.18.6 • DevTools 2.15.0 Xcode 13.4.1

Just add FBSDKCoreKit.xcframework, not _Basics

alperkayabasi commented 1 year ago

Same here with M1 Macbook & Xcode 14.1. Do you guys planning to fix this issue?

cwheeler42 commented 1 year ago

M1 Mac, using FBSDKCoreKit (only for analytics) via cocoapods. I too had to add the xcframework explicitly to my main project/target frameworks and embed & sign it to get past the crash. Please fix this. libs included via cocoapods should be built into the pod framework and included that way.

evilutioner commented 1 year ago

The same issue I can reproduce on my environment:

I was able to fix the problem by updating:

idish commented 1 year ago

It is an official library maintained by Facebook, so ridiculous that it is not fixed by now.. Are we expected to downgrade the library version then?

felipecastrosales commented 1 year ago

news about this? Same issue here.

derwaldgeist commented 1 year ago

Same issue here.

I have severe problems to get the SDK work with Unity 2019.4.40. I was forced to upgrade, because targeting Android 12 is now required by Google, and this broke the older Facebook SDK version 8 I was using. Upgrading for Android was already a nightmare. Now that I finally got this working, I ran into the iOS crash bug described here. Facebook's QA team seems to have serious issues. And they don't even seem to care about error reports. We're actually thinking about removing Facebook login from our app altogether. This takes up way too much dev time.

derwaldgeist commented 1 year ago

To recap in case someone is facing the same issue:

Thanks for the writeup. However, these manual tasks are unbearable if you're building new app versions often. Did you ever manage to automate this via Unity build scripts?

derwaldgeist commented 1 year ago

I was finally able to create a build script that resolved the problem for me on Unity 2019.4:

#if UNITY_IOS
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEditor.iOS.Xcode.Extensions;
using UnityEngine;
using System.Collections.Generic;
#endif

public class FixFacebookSDK15_1
{
#if UNITY_IOS

    [PostProcessBuild]
    public static void OnPostprocessBuild(BuildTarget target, string buildPath) {
        if (target != BuildTarget.iOS) return;
        Debug.Log("Applying Facebook SDK 15.1.0 workaround. Remove me once Facebook has patched this.");

        string pbxProjectPath = PBXProject.GetPBXProjectPath(buildPath);
        PBXProject proj = new PBXProject();
        proj.ReadFromFile(pbxProjectPath);
        string targetGuid = proj.GetUnityFrameworkTargetGuid();
        string mainTargetGuid = proj.GetUnityMainTargetGuid();

        List<string> frameworks = new List<string>();
        frameworks.Add("FBSDKCoreKit");
        frameworks.Add("FBSDKGamingServicesKit");

        foreach (string framework in frameworks) {
            var fileName = framework + ".xcframework";
            var src = Path.Combine("Pods", framework, "XCFrameworks", fileName);
            var fullSrc = Path.Combine(buildPath, src);
            var dest = Path.Combine("Frameworks", fileName);
            var findBefore = proj.FindFileGuidByProjectPath(src);
            var name = proj.AddFile(src, src);
            proj.AddFileToBuild(targetGuid, name);
            var findAfter = proj.FindFileGuidByProjectPath(src);
            proj.AddFileToEmbedFrameworks(mainTargetGuid, name);
        }
        proj.WriteToFile(pbxProjectPath);
    }

#endif
}

Not sure if this is a generic solution, but my app did not crash anymore. I only added two of the frameworks and was even able to use Facebook Login with this configuration. You might want to add more in your case if needed.

In case you are experiencing issues with other frameworks, you might want add a sequence number to the PostProcessBuild attribute, e.g. like this:

[PostProcessBuild(1000)]

to control when this script is being executed in the list of other post process build scripts.

The method AddFileToEmbedFrameworks doesn't seem to be available in newer Unity versions, so it might have to be replaced something else.

romas34 commented 1 year ago

Correct code for adding facebook's frameworks (working):

 [PostProcessBuild(1000)]
    public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToBuiltProject)  {
        if (buildTarget != BuildTarget.iOS) return;

        //Debug.Log("Applying Facebook SDK 15.1.0 workaround. Remove me once Facebook has patched this.");
        string projectPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
        PBXProject project = new PBXProject();
        project.ReadFromFile(projectPath);
        string mainTargetGuid = project.GetUnityMainTargetGuid();

        List<string> frameworks = new List<string> {
            "FBSDKCoreKit",
            "FBSDKGamingServicesKit"
        };
        foreach (string framework in frameworks) {
            string frameworkName = framework + ".xcframework";
            var src = Path.Combine("Pods", framework, "XCFrameworks", frameworkName);
            var frameworkPath = project.AddFile(src, src);
            project.AddFileToBuild(mainTargetGuid, frameworkPath);
            project.AddFileToEmbedFrameworks(mainTargetGuid, frameworkPath);
        }
        // Write.
        project.WriteToFile(projectPath);
    }
derwaldgeist commented 1 year ago

Ah, sorry, I kept some debug stuff in accidently. Glad you corrected the code.

derwaldgeist commented 1 year ago

Are you sure your code actually works? IIRC, I had to add the frameworks to the UnityFrameworkTarget as well.

romas34 commented 1 year ago

Are you sure your code actually works? IIRC, I had to add the frameworks to the UnityFrameworkTarget as well.

Yes.This is the working code. I spent a couple of days trying to fix this issue so that the app doesn't crash.

derwaldgeist commented 1 year ago

Ok, I can confirm it works on both 2019.4.31 and 2021.3.16. And it's simpler.

Was there a particular reason why you added the (1000) attribute?

derwaldgeist commented 1 year ago

Just realized that on Unity 2021, you need to add more frameworks. Here's my updated code:

#if UNITY_IOS
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEditor.iOS.Xcode.Extensions;
using UnityEngine;
using System.Collections.Generic;
#endif

// https://github.com/facebook/facebook-ios-sdk/issues/2121
public class FixFacebookSDK15_1
{
#if UNITY_IOS

    [PostProcessBuild]
    public static void OnPostprocessBuild(BuildTarget target, string buildPath) {
        if (target != BuildTarget.iOS) return;
        Debug.Log("Applying Facebook SDK 15.1.0 workaround. Remove me once Facebook has patched this.");

        string pbxProjectPath = PBXProject.GetPBXProjectPath(buildPath);
        PBXProject proj = new PBXProject();
        proj.ReadFromFile(pbxProjectPath);
        string mainTargetGuid = proj.GetUnityMainTargetGuid();

        List<string> frameworks = new List<string>();
        frameworks.Add("FBSDKCoreKit");
        frameworks.Add("FBSDKGamingServicesKit");
        frameworks.Add("FBAEMKit");
        frameworks.Add("FBSDKCoreKit_Basics");
        frameworks.Add("FBSDKLoginKit");
        frameworks.Add("FBSDKShareKit");
        foreach (string framework in frameworks) {
            var fileName = framework + ".xcframework";
            var src = Path.Combine("Pods", framework, "XCFrameworks", fileName);
            var fileGuid = proj.AddFile(src, src);
            proj.AddFileToBuild(mainTargetGuid, fileGuid);
            proj.AddFileToEmbedFrameworks(mainTargetGuid, fileGuid);
        }
        proj.WriteToFile(pbxProjectPath);
    }

#endif
}

With this setup, Facebook login is working. Not sure if you need even more frameworks if you're using other stuff. Interestingly, not even FBSDKLoginKit was needed on Unity 2019.4, although login worked fine.

romas34 commented 1 year ago

Was there a particular reason why you added the (1000) attribute?

No :) just to make sure it executes last.

adityawibisana commented 1 year ago

On my end, I have to change podfile, and change FBSDKCoreKit to version 15

pod 'FBSDKCoreKit', '~> 15.1'
derwaldgeist commented 1 year ago

I thought I had fixed this using the script above. The builds ran through and everything worked fine on my iPhone.

But now I wanted to push the version the app store. When uploading the build to the store, I got an error message:

image

It goes on like this:

image

This is for Unity 2019.4. On 2021.3, I am getting an additional error messages, which is related to Unity's own Framework:

image

It tells me that UnityFramework.framework it has a disallowed file "Frameworks". WTF?!

Any idea what is going on here and why the frameworks are in the wrong folder?! This is really driving me nuts. We have an important release soon, and it bugs if you notice something like this when trying to push your stuff to the stores... I wish we never integrated that crappy Facebook stuff in the first place.

derwaldgeist commented 1 year ago

Ok, I was able to fix the double reference to the Facebook libraries. This was actually an error in my post build script. Here's the updated version:

#if UNITY_IOS
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEditor.iOS.Xcode.Extensions;
using UnityEngine;
using System.Collections.Generic;
#endif

// https://github.com/facebook/facebook-ios-sdk/issues/2121
public class FixFacebookSDK15_1
{
#if UNITY_IOS

    [PostProcessBuild]
    public static void OnPostprocessBuild(BuildTarget target, string buildPath) {
        if (target != BuildTarget.iOS) return;
        Debug.Log("Applying Facebook SDK 15.1.0 workaround. Remove me once Facebook has patched this.");

        string pbxProjectPath = PBXProject.GetPBXProjectPath(buildPath);
        PBXProject proj = new PBXProject();
        proj.ReadFromFile(pbxProjectPath);
        string mainTargetGuid = proj.GetUnityMainTargetGuid();

        List<string> frameworks = new List<string>();
        frameworks.Add("FBSDKCoreKit");
        frameworks.Add("FBSDKGamingServicesKit");
        frameworks.Add("FBAEMKit");
        frameworks.Add("FBSDKCoreKit_Basics");
        frameworks.Add("FBSDKLoginKit");
        frameworks.Add("FBSDKShareKit");
        foreach (string framework in frameworks) {
            var fileName = framework + ".xcframework";
            var src = Path.Combine("Pods", framework, "XCFrameworks", fileName);
            var fileGuid = proj.AddFile(src, src);
            proj.AddFileToEmbedFrameworks(mainTargetGuid, fileGuid);
        }
        proj.WriteToFile(pbxProjectPath);
    }

#endif
}

The culprit was this line:

proj.AddFileToBuild(mainTargetGuid, fileGuid);
derwaldgeist commented 1 year ago

There are still two issues that require manual tweaks:

I'm now trying to find a way to automate these two steps. If any of these is missing, publishing to the AppStore will fail.

abdullah1826 commented 1 year ago

On my end, I have to change podfile, and change FBSDKCoreKit to version 15

pod 'FBSDKCoreKit', '~> 15.1'

I had the same version but it was giving me error now trying to change to older version

xinatcg commented 1 year ago

Same issue on Unity Facebook SDK 15.1

kirti-swiggy commented 1 year ago

Got fixed after updating Cocoapod to 1.12.0. Adding FBSDKCoreKit_Basics.xcframework in Frameworks, Libraries, and Embedded Content is causing build failure in CI systems.

carsonxw commented 1 year ago

Got if fixed by upgrading Cocoapod from 1.11.2 to 1.12.0.

Xcode version: 14.3 MacOS Version: Ventura 13.3 (22E252) Chip: Intel Core i7

devibrahimkarahan commented 1 year ago

As @hochungwong mentioned, when i upgrade cocoapods to 1.12.0 (mine was 1.11.3), its fixed.

umairali435 commented 1 year ago

Any update on this issue ?

vishna commented 1 year ago

seems to be fixed after upgrading cocoapods to 1.12.1 (flutter+facebook_app_events), so can confirm what @hochungwong & @devibrahimkarahan wrote

spo-mmorales commented 1 year ago

seems to be fixed after upgrading cocoapods to 1.12.1 (flutter+facebook_app_events), so can confirm what @hochungwong & @devibrahimkarahan wrote

It works for me

ivory-code commented 1 year ago

Got if fixed by upgrading Cocoapod from 1.11.2 to 1.12.0.

It works for me.

Xcode version: 14.3 (14E222b) MacOS: Ventura 13.3.1 (22E261) Processor: Intel Core i9

mtr1012 commented 1 year ago

Same issue on MacOS Sonoma. Upgrading the cocoapods to the latest version didn't help. Terrible facebook. Your SDK give us so much tired. We need to upgrade it constantly just to use your sign in feature? and your sdk breaks our project. Wtf?