facebook / facebook-sdk-for-unity

The facebook sdk for unity.
https://developers.facebook.com/docs/unity
Other
484 stars 256 forks source link

App crashes on launch when using SDK v7.21.2 on iOS 11 device #468

Open dhamelin opened 4 years ago

dhamelin commented 4 years ago

Environment

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

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

eladleb commented 4 years ago

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

eladleb commented 4 years ago

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());
    }
}
luuquangvu commented 4 years ago

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");
jannekaisgg commented 4 years ago

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.

p0w1nd commented 4 years ago

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.

ehidna commented 3 years ago

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

deirvlon commented 3 years ago

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

deirvlon commented 3 years ago

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