Facebook-sdk-for-unity: App crashes on launch when using SDK v7.21.2 on iOS 11 device

Created on 18 Aug 2020  ·  8Comments  ·  Source: facebook/facebook-sdk-for-unity

Environment

Describe your dev environment here, giving as many details as possible. If you have them, make sure to include:

  • Unity Editor Version: 2018.4.26f1
  • Unity SDK Version: 7.21.2
  • XCode: 11.6
  • Installation Platform & Version: iPad4,4 running [iOS] version 11.3.1

Expected Results

No crash

Actual Results

Game crash on launch:

dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from: /var/containers/Bundle/Application/6A540FA0-A178-4762-BE4D-1A32AC021D5C/XX.app/XX Reason: image not found

Same build is running OK on device with iOS 12.4.4 and 13.6

Steps to Reproduce

Just do a simple build using the specified version

bug

Most helpful comment

After took many hours and tried many times, I found a way to resolve this issue. Hope it helps you too.
Add this to your PostProcessBuild:

// Fixed Facebook SDK 7.21.2 issue for iOS < 12.2
project.AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");

All 8 comments

It's easily reproducible with the iOS simulator as well :(

I'm using the following post build script as a workaround for not crashing on iOS 11:

public class FacebookCrashIOS11 : ScriptableObject
{
    [PostProcessBuild]
    public static void OnPostProcess(BuildTarget buildTarget, string buildPath)
    {
        // Only for iOS
        if (buildTarget != BuildTarget.iOS)
        {
            return;
        }

        string projectPath = PBXProject.GetPBXProjectPath(buildPath);
        PBXProject project = new PBXProject();

        // Read.
        project.ReadFromString(File.ReadAllText(projectPath));
        string targetGUID = project.GetUnityMainTargetGuid();

        project.SetBuildProperty(targetGUID, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES"); // Facebook 7.21.2 crashed on iOS 11.0 without this line

        // Write.
        File.WriteAllText(projectPath, project.WriteToString());
    }
}

After took many hours and tried many times, I found a way to resolve this issue. Hope it helps you too.
Add this to your PostProcessBuild:

// Fixed Facebook SDK 7.21.2 issue for iOS < 12.2
project.AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");

I had same issue with ios < 12.2 and found the same workaround with LD_RUNPATH_SEARCH_PATHS in addition to ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES.

It would be great to add explicit documentation that these are required if a game supports older OS versions in the main documentation and in change log.

I'm also experiencing this "app crashes on launch" with my Unity game, but my iPhone XS has iOS 13.6.1

Unity 2019.4.9f1
Facebook SDK 7.21.2
iOS 13.6.1

=> Crash

Before upgrading to FBSDK 7.21.2 the project had FBSDK 7.19.0 and the game worked without crash.

I tried:

project.SetBuildProperty(targetId, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
project.AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");

but got this error when uploading:

ERROR ITMS-90206: "Invalid Bundle. The bundle at 'xxxxx.app/Frameworks/UnityFramework.framework' contains disallowed file 'Frameworks'."
Return status of iTunes Transporter was 1: ERROR ITMS-90206: "Invalid Bundle. The bundle at 'xxxxx.app/Frameworks/UnityFramework.framework' contains disallowed file 'Frameworks'."

I guess ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES causes this error for Unity 2019.4.9f1 because when I removed the second line (LD_RUNPATH_SEARCH_PATHS) and re-build I still got the same Invalid Bundle error.

Currently I have to revert back to FBSDK 7.19.0 and no more crash.

I had same issue with FBSDK 8.1.0 too.
ios 11 <= crash after upgrading FBSDK from 7.18.1

I'm also experiencing this "app crashes on launch" with my Unity game, but my iPhone XS has iOS 13.6.1

Unity 2019.4.9f1
Facebook SDK 7.21.2
iOS 13.6.1

=> Crash

Before upgrading to FBSDK 7.21.2 the project had FBSDK 7.19.0 and the game worked without crash.

I tried:

project.SetBuildProperty(targetId, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
project.AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");

but got this error when uploading:

ERROR ITMS-90206: "Invalid Bundle. The bundle at 'xxxxx.app/Frameworks/UnityFramework.framework' contains disallowed file 'Frameworks'."
Return status of iTunes Transporter was 1: ERROR ITMS-90206: "Invalid Bundle. The bundle at 'xxxxx.app/Frameworks/UnityFramework.framework' contains disallowed file 'Frameworks'."

I guess ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES causes this error for Unity 2019.4.9f1 because when I removed the second line (LD_RUNPATH_SEARCH_PATHS) and re-build I still got the same Invalid Bundle error.

Currently I have to revert back to FBSDK 7.19.0 and no more crash.

I also got
Return status of iTunes Transporter was 1: ERROR ITMS-90206: "Invalid Bundle. The bundle at 'xxxxx.app/Frameworks/UnityFramework.framework' contains disallowed file 'Frameworks'."

to solve it I just deleted my current Archive and Re-Archive it, then it accepted

I found a working form please check this link:
https://github.com/facebook/facebook-sdk-for-unity/issues/193#issuecomment-754953304

Was this page helpful?
0 / 5 - 0 ratings