facebook-sdk-for-unity
facebook-sdk-for-unity copied to clipboard
iOS app crash at startup
Checklist
- [16.0 ] I've updated to the latest released version of the SDK
- [Yes ] I've searched for existing GitHub issues
- [Yes ] I've looked for existing answers on Stack Overflow, the Facebook Developer Community Forum and the Facebook Developers Group
- [Yes ] I've read the Code of Conduct
- [Yes ] This issue is not security related and can safely be disclosed publicly on GitHub
Environment
- Unity Editor Version:
2022.2.19
- Unity Editor Version in Cloud Build:
2022.X
- Unity SDK Version:
16.0.0
- xcode in Unity build cloud Version:
14.2.0
(Have tried14.1.0
too) - Installation Platform & Verison:
iOS
version15.2
Goals
I want to build the project with Facebook SDK using Unity Cloud Build.
Expected Results
The app project don't crash on startup in iOS device.
Actual Results
The project built successively, uploaded to TestFlight but the app with Facebook SDK keep crashing at startup. I have removed Facebook SDK and tried again, it doesn't crash on startup, later I added latest Facebook SDK, it crashed again at startup.
Steps to Reproduce
- Add Facebook SDK v16.0 to your Unity project, add everything data as needed in Facebook Setting page.
- Upload the project to Unity Cloud Build using Unity Version Control
- Build the app, once built, download the .IPA file
- Upload the .IPA file to Apple App Store Connect using Transporter
- Download the app using TestFlight
- Start the app, this is where the app crash before Splash Screen
Code Samples & Details
For xcode 14.2 (experimental) in cloud build, no extra steps needed.
For xcode 14.1 in cloud build, I added this code (iOSBuild.cs) to make the build don't fail and to pass Apple Store Connect verifier:
#if UNITY_IOS && UNITY_EDITOR
using UnityEngine;
using UnityEditor.Callbacks;
using UnityEditor;
using UnityEditor.iOS.Xcode;
using System.IO;
public class iOSBuild
{
[PostProcessBuild]
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
{
// Performs any post build processes that we need done
if (buildTarget == BuildTarget.iOS)
{
// xCode workspace modifications
{
string projPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
PBXProject proj = new PBXProject();
proj.ReadFromFile(projPath);
string main = proj.GetUnityMainTargetGuid();
string framework = proj.GetUnityFrameworkTargetGuid();
proj.SetBuildProperty(main, "EMBEDDED_CONTENT_CONTAINS_SWIFT", "YES");
proj.SetBuildProperty(main, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
//proj.SetBuildProperty(main, "SWIFT_VERSION", "5.0");
proj.SetBuildProperty(framework, "EMBEDDED_CONTENT_CONTAINS_SWIFT", "NO");
proj.SetBuildProperty(framework, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
//proj.SetBuildProperty(framework, "SWIFT_VERSION", "5.0");
//proj.AddBuildProperty(main, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");
//proj.AddBuildProperty(framework, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");
proj.WriteToFile(projPath);
}
}
}
}
#endif
This is the crash log from iPhone simulator, seems like FBAEMKit wasn't included in the final product. Tested with SDK 16.0.1.
2023-06-03 13:34:40.519121+0200 My App[9209:106057] [general] Error loading /Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/UnityFramework.framework/UnityFramework (238): dlopen(/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: @rpath/FBAEMKit.framework/FBAEMKit Referenced from: <0F7CEFEA-027B-3BA7-B1D3-E981DFD46333> /Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/UnityFramework Reason: tried: '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/FBAEMKit.framework/FBAEMKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file), '/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file, no dyld cache), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file), '/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file, no dyld cache), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file) 2023-06-03 13:34:40.700404+0200 My App[9209:106057] [general] Error loading /Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/UnityFramework.framework/UnityFramework (238): dlopen(/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: @rpath/FBAEMKit.framework/FBAEMKit Referenced from: <0F7CEFEA-027B-3BA7-B1D3-E981DFD46333> /Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/UnityFramework Reason: tried: '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/FBAEMKit.framework/FBAEMKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file), '/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file, no dyld cache), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file), '/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file, no dyld cache), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/ My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file)
Same issue on our side, it's exploding by not including the FBAEMKit as expected.
Same issue here
It's crashing in the same way for me, for local builds. Doesn't seem to matter which version of the SDK I use either.
@SaariTech, @HanzaRu, @eranroza
FWIW - I think this might be a dupe/reoccurrence of this issue: https://github.com/facebook/facebook-sdk-for-unity/issues/659
@SaariTech, @HanzaRu, @eranroza
FWIW - I think this might be a dupe/reoccurrence of this issue: #659
The fix from that thread didn't work for me. I think it also needs one of these, or all of them:
- CocoaPods to 1.12.1
- XCode 14.3.1
Removing removing ":linkage => :static" fixed it in UCB at least for ad hoc profile.
You can do it in Unity as well:
I tried multiple permutations of the fixes, and I can say that on Unity Build Automation the only thing needed is to disable Link frameworks statically. (Add use_frameworks! to Podfile is already enabled by default in Google External Dependency Manager) This is also NOT necessary: addToAllTargets="true" I use xcode 14.2.0 and Unity mentioned that Cocoapods are either 1.12.0 or 1.12.1 on their machines.
Can confirm that Cocoapods version matters, the build crashes on Cocoapods 1.11.x
Thank you for coming to my Ted Talk, it works for release builds as well, they get uploaded to AppStore and no crashes. I also tested it on a Jenkins CI. I spend 3-4 full working days testing this, would be nice if someone could confirm that these changes work for them too.
@vg-swift Thank you for your post! So you solve it by unchecking the Link frameworks statically ? I am trying to see if 16.0.2 will solve the issue by itself, but I don't think so!
I could fix this by adding the addToAllTargets parameter in dependecies.xml ./Assets/FacebookSDK/Plugins/Editor/Dependencies.xml
<iosPods>
<iosPod name="FBSDKCoreKit_Basics" version="~> 15.1" **addToAllTargets="true"** />
<iosPod name="FBSDKCoreKit" version="~> 15.1" **addToAllTargets="true"**/>
<iosPod name="FBSDKLoginKit" version="~> 15.1" **addToAllTargets="true"**/>
<iosPod name="FBSDKShareKit" version="~> 15.1" **addToAllTargets="true"**/>
<iosPod name="FBSDKGamingServicesKit" version="~> 15.1" **addToAllTargets="true"**/>
</iosPods>
https://github.com/facebook/facebook-sdk-for-unity/issues/659#issuecomment-1643864386
My app crashes at launch after adding the Facebook 16.0.2 SDK with the same problem. When I unchecked "Link frameworks statically" I get errors building in XCode "DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead" for various SDKs such as AppLovin and Unity Ads mediation.
Same error with 17.0.2 SDK